我有一个数组,textboxes
它在运行时生成一个可变数量textboxes
的值,这些值textbox
已经创建到表单中。
int n;
TextBox[] tb;
public void AggiungiArmoniche()
{
n = int.Parse(textBox4.Text);
tb = new
TextBox[n];
for (int i = 1; i < tb.Length; i++)
{
tb[i] = new TextBox();
tb[i].Name = "textBox" + i;
tb[i].Location = new Point(100 *i, 163);
tb[i].Size = new Size(48, 20);
tb[i].KeyPress += System.Windows.Forms.KeyPressEventHandler(textBoxP_KeyPress);
groupBox1.Controls.Add(tb[i]);
}
}
private void textBoxP_KeyPress(object sender, KeyPressEventArgs e)
{
// statements of the event
}
当我移动到我将事件与事件处理程序相关联的行时,它会给出错误,它不是比赛中的有效构造”(特别是在单词中keypresseventhandler
)
关联中是否存在语法错误?