I have a listBox1 with 4 items inside. I can use the keys to move up-down between the items or click with the mouse once on each item in both cases the selected items will be highlight with blue marked .
I want when I click on an item or when I move the keys up and down over the items it will change the label.Text with the current item name.
For example in on the item moses so label1.Text will contain moses.
Moved to the next item with arrow key up so now label1.Text contain daniel.
Clicked with the mouse on the item number 3 now label1.Text will contain dana.
Tried with this:
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
//listBox1.Items.Add(fsi[i].Name + Environment.NewLine);
label2.Text = listBox1.Items[i].ToString();
}
}
But its not worrking.
Works for me.