我刚刚使用窗体窗体应用程序设计了一个简单的“For循环”。我希望这将只能点击一次&它不会重复相同的信息,如果我点击按钮。我怎么能这样做?感谢 这里是我的代码:for循环窗口窗体应用程序
int count;
for (count = 0; count < 5; count = count + 1)
{
listBox1.Items.Add("This is count: " + count);
}
const string textEnd = "Done!!!";
{
listBox1.Items.Add(textEnd);
}
====附加信息=== 我做了现在这个样子。这只会点击一次,但按钮仍然可用。我认为这是确定:
int count;
for (count = 0; count < 5; count++)
{
string newItem = "This is count: " + count;
if (listBox1.Items.IndexOf(newItem) < 0)
{
listBox1.Items.Add(newItem);
}
}
const string textEnd = "Done!!!";
if (listBox1.Items.IndexOf(textEnd) <0)
{
listBox1.Items.Add(textEnd);
}
的建议:申报数为和使用++来增量:for(int count = 0; count <5; count ++)... – 2009-05-20 08:28:20