我動態創建一個表單和裏面我創建了一個按鈕,但是當我嘗試我的功能添加到該按鈕,它給出了這樣的錯誤:添加功能,動態按鈕在C#
Method name expected.
我使用以下代碼:
{
...
Form newForm = new Form();
newform.Size = new Size(477, 222);
Button btn = new Button();
btn.Size = new Size(121, 23);
btn.Location = new Point(231, 102);
btn.Text = "Text";
btn.Click += new EventHandler(Funct(label1.Text, label12.Text));
newForm.Controls.Add(btn);
}
public void Funct(string stringA, string stringB)
{
StreamWriter write = new StreamWriter(path);
write.WriteLine(stringA + "-" + stringB);
write.Close();
}
我該如何解決這個問題?