winforms - C# TabControl, How create custom TabPages collection editor? -


i have customized tabpage, found there problems follows:

first, create 2 custom tabpage, worked.

but there problem when closed document , reopened document:

enter image description here

look, tabpage becomes four, found problem in "designer.cs" document.

//  // blk_tabcontrol1 //  this.blk_tabcontrol1.controls.add(this.blk_tabpage6); this.blk_tabcontrol1.controls.add(this.blk_tabpage7); this.blk_tabcontrol1.location = new system.drawing.point(4, 12); this.blk_tabcontrol1.name = "blk_tabcontrol1"; this.blk_tabcontrol1.selectedindex = 0; this.blk_tabcontrol1.size = new system.drawing.size(604, 196); this.blk_tabcontrol1.tabindex = 14; this.blk_tabcontrol1.tabpages.addrange(new system.windows.forms.tabpage[] { this.blk_tabpage6, this.blk_tabpage7}); 

after normal tabcontrol add tabpage, there no "tabpages.addrange()" code, how can fix it?

here code:

 public class blk_tabpagecollectioneditor : collectioneditor  {         public blk_tabpagecollectioneditor(type type)             : base(type)         {          }          protected override bool canselectmultipleinstances()         {             return false;         }           protected override type createcollectionitemtype()         {             return typeof(blk_tabpage);         }          protected override object createinstance(type itemtype)         {             blk_tabpage tabpage = (blk_tabpage)itemtype.assembly.createinstance(itemtype.fullname);              idesignerhost host = (idesignerhost)this.getservice(typeof(idesignerhost));             host.container.add(tabpage);             //this.context.container.add(tabpage);              tabpage.text = tabpage.name;             return tabpage;         }   }  public class blk_tabcontrol : tabcontrol {     [editorattribute(typeof(blk_tabpagecollectioneditor), typeof(uitypeeditor))]     [mergableproperty(false)]     public new tabcontrol.tabpagecollection tabpages     {                 {             return base.tabpages;         }     }  } 

thanks in advance.

i have tried code. looks fine. based on designer-generated code , image description thing can suggest hide serialization of tabpages property:

    [designerserializationvisibility(designerserializationvisibility.hidden)]     [editorattribute(typeof(blk_tabpagecollectioneditor), typeof(uitypeeditor))]     [mergableproperty(false)]     public new tabcontrol.tabpagecollection tabpages     {                 {             return base.tabpages;         }     } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -