我正在尝试运行时的属性值。首先,我尝试使用一个人的name属性,但我不知道如何完成下面的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??
}
}
答案 0 :(得分:0)
in
public Edit_Details(Student student)
{
InitializeComponent();
nameLabel.Text = student.Forename;
savebutton.Click+=(sender,e)=>
{
savebutton.Text=student.ChangeName(editNameTextBox.Text);
};
}