private void Form1_Load(object sender, EventArgs e)
{
listBox1.SelectionMode = SelectionMode.MultiExtended;
for (int i = 0; i < 5; i++)
{
listBox1.Items.Add("Blah");
listBox1.Items.Add(" Foo");
listBox1.Items.Add(" Something");
}
}
private void listBox1_Click(object sender, EventArgs e)
{
if (listBox1.Items[listBox1.SelectedIndex].ToString() != "Blah")
{
if (listBox1.SelectedIndex < listBox1.Items.Count - 3)
{
for (int i = listBox1.SelectedIndex; i < listBox1.Items.Count; i++)
{
if (listBox1.Items
.ToString() == "Blah")
{
listBox1.SelectedIndex = -1;
listBox1.SetSelected(i, true);
listBox1.SetSelected(i + 1, true);
listBox1.SetSelected(i + 2, true);
break;
}
}
}
else
{
listBox1.SelectedIndex = -1;
listBox1.SetSelected(listBox1.Items.Count -1, true);
listBox1.SetSelected(listBox1.Items.Count - 2, true);
listBox1.SetSelected(listBox1.Items.Count - 3, true);
}
}
else
{
listBox1.SetSelected(listBox1.SelectedIndex + 1, true);
listBox1.SetSelected(listBox1.SelectedIndex + 2, true);
}
}