I went about creating a custom TabControl widget so that I could accurately paint the tab with a close X on the right edge of the tab. I have a custom array class that holds all of the tabs.
So I override the CreateControlsInstance instance class and redefine the Controls class so 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; }
}
I then create the 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();
}
}
Currently this works but if the Controls class can still call methods SetChildIndex, etc which changes the underlying arraylist but not the tabPages array.
I would like to be able to eliminate the need for the new ControlCollection class to have to use the base class for registering the new xTabPage objects with the xTabControl.
I have already been through the class structure with .Net Reflector. I am hoping to not have to copy half of the Control class in order to get the registration of the new widget to work.
I know this is a long shot but has anyone had any success doing this?