我剛剛使用窗體窗體應用程序設計了一個簡單的「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