c# - Hiding tab headers in tabControl in winforms -
i'm trying hide tab headers in tabcontrol, it's shown here in this link, getting error in designer's code. once change both lines, this:
severity code description project file line message designer cannot process unknown name 'selectedindex' @ line 43. code within method 'initializecomponent' generated designer , should not manually modified. please remove changes , try opening designer again. c:\users\krzysztof\documents\visual studio 2015\projects\daneuzytkownika3\daneuzytkownika3\tabcontroller.designer.cs 44
severity code description project file line error cs1061 'tabcontroller' not contain definition 'selectedindex' , no extension method 'selectedindex' accepting first argument of type 'tabcontroller' found (are missing using directive or assembly reference?) daneuzytkownika3 c:\users\krzysztof\documents\visual studio 2015\projects\daneuzytkownika3\daneuzytkownika3\tabcontroller.designer.cs 43
line 43 in designer's code of form is:
this.tabcontrol1.selectedindex = 0; could please tell me, how fix it?
tablesstabcontrol.cs
namespace hiding { class tablesstabcontrol : form1 { protected override void wndproc(ref message m) { // hide tabs trapping tcm_adjustrect message if (m.msg == 0x1328 && !designmode) m.result = (intptr)1; else base.wndproc(ref m); } } } form1.designer.cs
namespace hiding { partial class form1 { /// <summary> /// required designer variable. /// </summary> private system.componentmodel.icontainer components = null; /// <summary> /// clean resources being used. /// </summary> /// <param name="disposing">true if managed resources should disposed; otherwise, false.</param> protected override void dispose(bool disposing) { if (disposing && (components != null)) { components.dispose(); } base.dispose(disposing); } #region windows form designer generated code /// <summary> /// required method designer support - not modify /// contents of method code editor. /// </summary> private void initializecomponent() { this.tabcontrol1 = new tablesstabcontrol(); //this.tabcontrol1 = new system.windows.forms.tabcontrol(); this.tabpage1 = new system.windows.forms.tabpage(); this.tabpage2 = new system.windows.forms.tabpage(); this.tabcontrol1.suspendlayout(); this.suspendlayout(); // // tabcontrol1 // this.tabcontrol1.controls.add(this.tabpage1); this.tabcontrol1.controls.add(this.tabpage2); this.tabcontrol1.location = new system.drawing.point(31, 12); this.tabcontrol1.name = "tabcontrol1"; this.tabcontrol1.selectedindex = 0;//line error this.tabcontrol1.size = new system.drawing.size(200, 100); this.tabcontrol1.tabindex = 0; // // tabpage1 // this.tabpage1.location = new system.drawing.point(4, 22); this.tabpage1.name = "tabpage1"; this.tabpage1.padding = new system.windows.forms.padding(3); this.tabpage1.size = new system.drawing.size(192, 74); this.tabpage1.tabindex = 0; this.tabpage1.text = "tabpage1"; this.tabpage1.usevisualstylebackcolor = true; // // tabpage2 // this.tabpage2.location = new system.drawing.point(4, 22); this.tabpage2.name = "tabpage2"; this.tabpage2.padding = new system.windows.forms.padding(3); this.tabpage2.size = new system.drawing.size(192, 74); this.tabpage2.tabindex = 1; this.tabpage2.text = "tabpage2"; this.tabpage2.usevisualstylebackcolor = true; // // form1 // this.autoscaledimensions = new system.drawing.sizef(6f, 13f); this.autoscalemode = system.windows.forms.autoscalemode.font; this.clientsize = new system.drawing.size(284, 261); this.controls.add(this.tabcontrol1); this.name = "form1"; this.text = "form1"; this.tabcontrol1.resumelayout(false); this.resumelayout(false); } #endregion private tablesstabcontrol tabcontrol1; //private system.windows.forms.tabcontrol tabcontrol1; private system.windows.forms.tabpage tabpage1; private system.windows.forms.tabpage tabpage2; } }
i have created project , implemented tab control given in example follows:
class tablesstabcontrol : tabcontrol { protected override void wndproc(ref message m) { // hide tabs trapping tcm_adjustrect message if (m.msg == 0x1328 && !designmode) m.result = (intptr)1; else base.wndproc(ref m); } } then upon rebuilding project add new tablesstabcontrol test form using designer. within designer, can switch between tabs using visible headers.
at runtime, headers disappear intended. have 2 tabs; able select between tabs using following code:
// selects first tab: tablesstabcontrol1.selectedindex = 0; // selects second tab: tablesstabcontrol1.selectedindex = 1; additionally, in form1.designer.cs, have line 48 follows:
this.tablesstabcontrol1.selectedindex = 0; which poses no difficulty me.
have tried closing documents, cleaning solution, rebuilding , reopening designer?
Comments
Post a Comment