c# - find a control inside a tabpage that is created with a usercontrol -


i have created usercontrol, have tabcontrol in there tabpage contains 2 buttons, when button1 clicked, creates new tabpage , user control added controls through

tab = new tabpage(); usercontrol1 uc = new usercontrol1();            tab.controls.add(uc); tab.name = "0"; tab.text = tab.name; tabcontrol1.tabpages.add(tab); 

now when click button2, should put text in textbox inside usercontrol-tabpage created, implemented code,

textbox sel = (textbox)tabcontrol1.tabpages["0"].controls["textbox1"]; sel.text = "ssss"; 

but returns runtime error, saying cannot find said control, tried

textbox sel = (textbox)tabcontrol1.tabpages["0"].controls[0]; sel.text = "ssss"; 

but still returns runtime error, saying cast usercontrol cannot applied textbox. dont know means.. pls me in this.. tried putting in controls[1] returned runtime error, of outofbounds exception. dont know do, or how find control inside usercontrol in tabpage... pls hellp

it's little bit unclear if textbox exists in usercontrol, assume does. in case, have reference usercontrol first:

usercontrol1 uc1 = tabcontrol1.tabpages["0"].controls[0] usercontrol1; if (uc1 != null) {   textbox sel = uc1.controls["textbox1"] textbox;   if (sel != null) {     sel.text = "ssss";   } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -