-1

実行時にプロパティの値を取得しようとしています。まず、人の 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??
    }
}
4

1 に答える 1

0

 public Edit_Details(Student student)
    {
        InitializeComponent();
        nameLabel.Text = student.Forename;
        savebutton.Click+=(sender,e)=>
          {
             savebutton.Text=student.ChangeName(editNameTextBox.Text);
          };
    }
于 2013-04-04T22:56:56.297 に答える