我没有从Visual Studio中收到任何错误,所以我认为代码是正确的。当我运行代码时,我按下按钮(button1
),但没有任何反应。WinForms按钮单击事件不能触发
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
int b = 1;
int c = 1;
listBox1.Text += a.ToString();
listBox1.Text += b.ToString();
for (int i = 0; i < 20; i++)
{
c = b;
b = a + b;
a = c;
listBox1.Text += b.ToString();
}
}
一对于从Control继承的Text属性,ListBox没有有意义的实现。它在**属性窗口中隐藏**的原因。它显示*多个*字符串,而不仅仅是一个。使用其Items.Add()方法或使用Label。 – 2014-10-05 16:36:06