c# - Keep layout the same when adding a tab [SOLUTION BELOW CODE] -
i quite new @ c# need simple possible, have coded web browser tabs, when click add together tab opens webrowser in new tab on google.co.uk need new tab have adressbar , navigate button me able navigate url in new tab. want add together tab button adds tab totally seperate web browser , seperate adressbar , seperate navigate button. here code far:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace windowsformsapplication1 { public partial class form1 : form { public form1() { initializecomponent(); } private void button2_click(object sender, eventargs e) { tabpage tb = new tabpage("tab"); webbrowser wb = new webbrowser(); wb.dock = dockstyle.fill; wb.navigate("www.google.co.uk"); tabcontrol1.tabpages.add(tb); tb.controls.add(wb); tabcontrol1.selecttab(tb); } private void closealtf4toolstripmenuitem_click(object sender, eventargs e) { this.close(); } private void addtabtoolstripmenuitem_click(object sender, eventargs e) { tabpage tb = new tabpage("tab"); webbrowser wb = new webbrowser(); wb.dock = dockstyle.fill; wb.navigate("www.google.co.uk"); tabcontrol1.tabpages.add(tb); tb.controls.add(wb); tabcontrol1.selecttab(tb); tb.controls.add(new textbox()); } private void button1_click_1(object sender, eventargs e) { webbrowser1.navigate(textbox1.text); } private void removetabtoolstripmenuitem_click(object sender, eventargs e) { tabcontrol1.tabpages.remove(tabcontrol1.selectedtab); } }
}
solution:
i got work usercontrol, designed usercontrol form , added tabs using code:
tabpage tb = new tabpage("tab"); menustrip ms = new menustrip(); tabcontrol1.tabpages.add(tb); tb.controls.add(ms); tb.controls.add(new usercontrol1()); tabcontrol1.selecttab(tb);
a user command best way maintain same layout. can think of panel. can maintain controls grouped , maintain same look. add together website gui panel add together panel command tabcontrol.
something like
tabpage tb = new tabpage("tab"); menustrip ms = new menustrip(); ms.items.add("add"); ms.items[0].click += new eventhandler(addmenu_click); tb.controls.add(ms); tb.controls.add(new usercontrol(tabcontrol1)); //if need update tab text tabcontrol1.tabpages.add(tb);
this create menu strip on each tabpage , user command or "panel" fill in rest.
c#
No comments:
Post a Comment