winforms - how to add tabs to C# tab control programtically, and add browser and text box? -


i'm using visual studio community 2015 i'm using c#.

i want able add tabs programmatically when hit button in windows form want add web browser component , textbox when new tab created.

how can this?

i've tried in past no avail. when switching tabs lose data of original tab.

this i've used doesn't work.:

          public browser()     {         initializecomponent();         webbrowser.scripterrorssuppressed = true;         webbrowser.dock = dockstyle.fill;         webbrowser.visible = true;         webbrowser.documentcompleted += webbrowser_documentcompleted;         webbrowser.navigate("http://bing.com");       ///  webbrowser.anchor = anchorstyles.top & anchorstyles.bottom & anchorstyles.right & anchorstyles.left;          tabcontrol1.anchor = anchorstyles.top & anchorstyles.bottom & anchorstyles.right & anchorstyles.left;         tabcontrol1.tabpages.add("new tab");         tabcontrol1.selecttab(i);         tabcontrol1.selectedtab.controls.add(webbrowser);         += 1;     } 

main tab

secondary tab

you might wanna try this. maybe forgot add tabcontrol in main container.

using system; using system.drawing; using system.windows.forms;  namespace windowsformsapplication1 {     public partial class form1 : form     {         private webbrowser webbrowser;         private tabcontrol tabcontrol1;         private int = 0;          public form1()         {             initializecomponent();         }          private void button1_click(object sender, eventargs e)         {             createbrowser();         }          private void createbrowser()         {             webbrowser = new webbrowser();             tabcontrol1 = new tabcontrol();              webbrowser.scripterrorssuppressed = true;             webbrowser.location = new point(0, 0);             webbrowser.dock = dockstyle.fill;             webbrowser.visible = true;             //webbrowser.documentcompleted += webbrowser_documentcompleted;             webbrowser.navigate("http://bing.com");             ///  webbrowser.anchor = anchorstyles.top & anchorstyles.bottom & anchorstyles.right & anchorstyles.left;             tabcontrol1.anchor = anchorstyles.top & anchorstyles.bottom & anchorstyles.right & anchorstyles.left;             tabcontrol1.tabpages.add("new tab");             tabcontrol1.selecttab(i);             tabcontrol1.selectedtab.controls.add(webbrowser);             tabcontrol1.size = new size(500, 300);             tabcontrol1.location = new point(0, 100);             += 1;              this.controls.add(tabcontrol1);         }     } } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -