按钮返回对属性所做的更改
本文关键字:返回 属性 按钮 | 更新日期: 2023-09-27 18:07:45
我试图在运行时属性的值。首先,我试图用一个人的名称属性做到这一点,但我不确定如何完成下面的if语句。我想重新打开我的Form2,它把学生作为一个参数,它将显示他们的所有细节。任何帮助或建议将不胜感激。如果我这样做是完全错误的,请让我知道给我一些指导或建议如何在运行时编辑属性数据。
public class Student :IPerson
{
//Method that changes the original name
public string ChangeName(string newForename)
{
_forename = newForename;
return _forename;
}
}
public partial class Edit_Details : Form
{
public Edit_Details(Student student)
{
InitializeComponent();
nameLabel.Text = student.Forename;
student.ChangeName(editNameTextBox.Text);
//if(savebutton.Click) //how can I get this to replace the old name with the new one when the button is pressed??
}
}
in
public Edit_Details(Student student)
{
InitializeComponent();
nameLabel.Text = student.Forename;
savebutton.Click+=(sender,e)=>
{
savebutton.Text=student.ChangeName(editNameTextBox.Text);
};
}