Add controls to a tab page at run-time
-
Hi all, I want to add a ListBox into a tab page at run time, not design time. Can someone give me a clue. Thanks
I appreciate your help all the time... CodingLover :)
-
Hi all, I want to add a ListBox into a tab page at run time, not design time. Can someone give me a clue. Thanks
I appreciate your help all the time... CodingLover :)
this is something i made a few days ago... private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { RefreshList(); switch (tabControl1.SelectedIndex) { case 0: tabPage1.Controls.Add(groupBox2); tabPage1.Controls.Add(groupBox1); break; case 1: tabPage2.Controls.Add(groupBox2); tabPage2.Controls.Add(groupBox1); break; case 2: tabPage3.Controls.Add(groupBox2); tabPage3.Controls.Add(groupBox1); break; default: break; } }
-
this is something i made a few days ago... private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { RefreshList(); switch (tabControl1.SelectedIndex) { case 0: tabPage1.Controls.Add(groupBox2); tabPage1.Controls.Add(groupBox1); break; case 1: tabPage2.Controls.Add(groupBox2); tabPage2.Controls.Add(groupBox1); break; case 2: tabPage3.Controls.Add(groupBox2); tabPage3.Controls.Add(groupBox1); break; default: break; } }
Mainly what I want to do is this. In my tab control added three tabs. Initially added ListBox to the first tab. Next time, if the tab page 1 have a list box I want to add to the next tab page.
I appreciate your help all the time... CodingLover :)
-
Mainly what I want to do is this. In my tab control added three tabs. Initially added ListBox to the first tab. Next time, if the tab page 1 have a list box I want to add to the next tab page.
I appreciate your help all the time... CodingLover :)
Michael gave you the answers, use selected tab to identify the page, check if the control has been added to the pages control collection if it is missing then add it to the collection. All the commands are in Michaels example, you can't expect someone to write it to match your somewhat twisted logic.
Never underestimate the power of human stupidity RAH
-
Michael gave you the answers, use selected tab to identify the page, check if the control has been added to the pages control collection if it is missing then add it to the collection. All the commands are in Michaels example, you can't expect someone to write it to match your somewhat twisted logic.
Never underestimate the power of human stupidity RAH
I'm not expecting any code pal. :) I just wonder how to find a page has a control or not. In other words, how to find something is contain in a specific tab page.
I appreciate your help all the time... CodingLover :)
-
I'm not expecting any code pal. :) I just wonder how to find a page has a control or not. In other words, how to find something is contain in a specific tab page.
I appreciate your help all the time... CodingLover :)
check the tab pages control collection
Never underestimate the power of human stupidity RAH
-
check the tab pages control collection
Never underestimate the power of human stupidity RAH
may be this code could help you... // use this one to find a control on you tabcontrol tabControl1.Controls.Find("Control"); //use this one to see if there any controls on the tab page tabControl1.Controls.Count Or //getting the number of tab pages... tabControl1.TabCount