doubleclicking on one of the listboxes will make a handler named something like
listBox1_SelectedIndexChanged. click on second listbox, open it's property page, go to it's events, find
SelectedIndexChanged, and in dropdown list next to it choose
listBox1_SelectedIndexChanged. Repeat procedure for as many listboxes as you like.
If you want to programatically add event handlers, use syntax (copied from form1.desinger.cs):
- listBox2.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
Finally, you should have handler that looks like this:
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
-
{
-
this.Text /*form title*/= ((TabControl)(((TabPage)(((ListBox)sender).Parent)).Parent)).SelectedIndex.ToString();
-
}
and sets forms's title to 0, 1, 2, ... depending on tab's index in which listbox was nested.
note:
sender=listbox
sender.parent=tabpage
sender.parent.parent=tabcontrol
tabcontrol has property selectedindex, and that is what you need
ps. This is
C# synthax.