これはコードです:
private void Lightnings_Mode_Load(object sender, EventArgs e)
{
this.Size = new Size(416, 506);
this.Location = new Point(23, 258);
listBoxIndexs();
this.listBox1.SelectedIndex = 0; // This will make the listBox when showing it first time first item to be already selected !!!!!!
}
private void listBoxIndexs()
{
for (int i = 0; i < Form1.lightningsRegions.Count; i++)
{
listBox1.Items.Add(Form1.lightningsRegions[i]);
}
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
item = listBox1.SelectedItem.ToString();
this.f1.PlayLightnings();
f1.pdftoolsmenu();
if (item != null && !pdf1.Lightnings.Contains(item.ToString()))
{
pdf1.Lightnings.Add(item.ToString());
}
}
Form1の2つの場所で変数アイテムを使用しています。1回は文字列を抽出して内部の数字を再生し、もう1回はリストライトニングにアイテムを追加します。
初めて数字を演奏するために私はそれが欲しいです:
this.listBox1.SelectedIndex = 0;
ボタンをクリックしてリストボックスを表示/開いたら、最初のアイテムをすでに再生できるようにしたいので。
Lightningsリストにアイテムを追加する2番目の場所では、最初にいずれかのアイテムをクリックした場合にのみアイテムが追加されるようにします。私がしたので:
this.listBox1.SelectedIndex = 0;
リストボックスを表示/開くと、Lightningsにアイテムが自動的に追加されます。最初にアイテムをクリックした場合にのみリストに追加する必要があります。一方、選択したいので、selectedindex=0にします。私はそれを再生することができます。
では、再生するためとリストにアイテムを追加するために、SelectedIndex = 0をどのように分離できますか?