winforms - How do I access controls in a tabcontrol? -


i'm writing app in c# following arrangement of controls on form.

first, there child form contains splitcontainer, comes 2 panels, panel1 on left , panel2 on right. panel1 contains checkboxes , textboxes. panel2 contains tab control. each tab, when created programatically, contains checkboxes , textboxes.

when click save @ top of child form, data controls in panel1 save binary file correctly. save routine have iterate through each tab in tab control , save data checkboxes , textboxes in each tab. here have far:

             foreach (tabpage tab in tabcontrol1.tabpages)             {                 string question = tbquestion.text(tabcontrol1.selectedindex);             }  

unfortunately, tbquestion.text ends wiggly line under it, error message indicating "doesn't exist in current context." same happen other controls in each tab. need access controls in each tab?

could try :

foreach (tabpage tab in tabcontrol1.tabpages) {     control ctl = tp.controls.cast<control>().where(c=>c.name=="tbquestion").firstordefault();      string question = ... ctl.text; } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -