I started creating my own TabControl widget so that I could accurately draw a tab with closed X on the right edge of the tab. I have my own array class that contains all the tabs.
Therefore, I override the instance class CreateControlsInstance and override the Controls class so that I can hide it during reflection serialization.
protected override Control.ControlCollection CreateControlsInstance() { return new ControlCollection( this ); } [Browsable( false ), DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden )] private new Control.ControlCollection Controls { get { return base.Controls; } }
Then I create an override class.
public new class ControlCollection: Control.ControlCollection { private xTabControl owner; public ControlCollection( xTabControl owner ): base( owner ) { this.owner = owner; } public override void Add( Control value ) { if ( !(value is xTabPage) ) throw new Exception( "The control must be of type xTabPage" ); xTabPage tabPage = (xTabPage)value; if ( !owner.inTabEvent ) owner._tabPages.Add( tabPage ); base.Add( value ); } public override void Remove( Control value ) { if ( !(value is xTabPage) ) throw new Exception( "The control must be of type JDMX.Widget.xTabPage" ); if ( !owner.inTabEvent ) { xTabPage tabPage = (xTabPage)value; owner._tabPages.Remove( tabPage ); } base.Remove( value ); } public override void Clear() { owner._tabPages.Clear(); } }
This currently works, but if the Controls class can still call SetChildIndex methods, etc., which modifies the underlying arraylist, but not the tabPages array.
I would like to be able to eliminate the need for the new ControlCollection class to use the base class to register new xTabPage objects with xTabControl.
I already went through the class structure with .Net Reflector. I hope you donβt have to copy half of the Control class to get a new widget registered.
I know this is a long shot, but did anyone succeed?
source share