private void ChangeTab(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 1)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
foreach (Value mn in ValueList)
{
listBox2.Items.Add(mn.getName());
}
}
if (tabControl1.SelectedIndex == 0)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
foreach (Value mn in ValueList)
{
listBox1.Items.Add(mn.getName());
}
}
}
|
What's the error in this code?I want to show value from listbox1 to listbox2?
Nilanka DharmadasaPosted Jan 19, 2010, 11:19 PM
Did you bind the 'ChangeTab' method to TabControl's 'SelectedIndexChanged' event? If you didnt do that, you can do that by adding following line in red to your form constructor as given below.
public Form1()
{
InitializeComponent();
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.ChangeTab);
}
If you find my answer helpful, please do not forget to tick 'Do you like this answer' checkbox.
MilosPosted Jan 20, 2010, 12:59 PM
Sam HobbsPosted Jan 19, 2010, 11:22 PM
MilosPosted Jan 19, 2010, 6:32 PM
Sam HobbsPosted Jan 19, 2010, 6:03 PM