winforms - C# simpler way to find selected tab and do something with a control within it -


i trying find easier way implement in code. not mind typing of concerned amount of code going have. code sample here small example of trying do. when said , done have 3 different buttons doing different actions 50 different tabs.

i new c# forgive inexperience please , not looking code me if can guide me in right direction type, function, method need use efficiently appreciated.

anyway code. making customized web browser job have 50+ tabs each tool need able access , making button, forward, refresh etc need function on tab have active.

private void backtoolstripmenuitem_click(object sender, eventargs e)     {         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["inettab"])         {             inettabbrowser.goback();             textbox1.text = inettabbrowser.url.tostring();         }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["frontierwikitab"])         {             frontierwikibrowser.goback();             textbox1.text = frontierwikibrowser.url.tostring();         }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["loopcaretab"])         {             loopcarebrowser.goback();             textbox1.text = loopcarebrowser.url.tostring();         }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["vnettab"])         {             vnetbrowser.goback();             textbox1.text = vnetbrowser.url.tostring();         }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["cdpitab"])         {             cdpibrowser.goback();             textbox1.text = cdpibrowser.url.tostring();          }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["lolatab"])         {             lolabrowser.goback();             textbox1.text = lolabrowser.url.tostring();          }         if (frontiertabinner.selectedtab == frontiertabinner.tabpages["billinglookuptab"])         {             billinglookupbrowser.goback();             textbox1.text = billinglookupbrowser.url.tostring();         } 

i know there easier way cannot seem find it.

any assistance helpful.

thanks

you can find webbrowser control in selected tab easily:

private void backtoolstripmenuitem_click(object sender, eventargs e) {     webbrowser wbcontrol =        frontiertabinner.selectedtab.controls.oftype<webbrowser>().firstordefault();     wbcontrol.goback();     textbox1.text = wbcontrol.url.tostring(); } 

assuming have 1 webbrowser control in each tab. otherwise you'd have know either name or index in order find it.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -