ウィンドウフォームアプリケーションを使用して、単純な「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);
}
====追加情報===私は今この方法でそれを作りました。これは1回だけクリックしますが、ボタンは引き続き有効です。これは大丈夫だと思います:
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);
}