Navbar will load here

How to Change the colours of a Tabcontrols Header Item.

The first thing to do is to set the TabControls DrawMode to OwnerDrawFixed as shown above. Then simply add the code shown below.

I'll leave you the challenge of modifying the code to show an image.
A Completely OwnerDraw TabControl.

A little more work involved here than in the previous case, but definately worth it. Add a new UserControl to your project and replace the code with that shown below. As you can see we have made the BackColor property of the TabControl Visible in the Designer and put a custom background behind Transparent Tabpages.
This control has been updated to incorporate a modified version of the SelectedIndexChanging event in Matt Hinz and Ken Tuckers Tabcontrol source.
The project needs a custom designer to get the Design time painting to behave properly, but that's something for a later project.
You'll find TabControlEx on my Controls page with all the work already done.

Modify the appearance to reflect the style you want.
Associate a ContextMenu with the TabItem headers of a Tabcontrol.

A nice little trick. At least I think it is.


Hide and Show Tabpages in a Tabcontrol.

The Visible property has not been implemented on the TabControl, and there is no Insert method.
The following functions are a workaround.


An Alternative approach to TabPage Navigation.

As well as a customised Navigation System this option allows you to Enable Disable TabPages without the need to use a modified TabControl.
This tip is mainly property manipulation.

For a better solution see the PanelManager control on my Custom Controls page.

Enjoy!
Tabpage order has changed.

This is not random. The tabpages appear in their zOrder.
I do not know why the zOrder changes but it does.
The simple solution to reapplying the zOrder is, starting from the first tabitem and working your way to the last, select each tabpage in turn, in the order in which they should appear, (make sure the tabpage is selected and not the tabcontrol) and right click the tabpage. A menu will appear and you should select SendToBack. You may need to close and reopen the form designer to see the result in the IDE but it will be correct at runtime.

Reposition TabItems at Runtime.

If you want the ability to Drag Tabs around at runtime then this code will do it for you.
Add a TabControl (with the AllowDrop property set to True) and the code below to your form.
This code is based upon code submitted to CodeProject by Paul Auger. The original is here.

Assumes your Tabcontrol is named TabControl1.
Add Mnemonic support to TabPages.

You must resort to drawing the Tabitems yourself to get the underlined character to show.
This is a very basic ownerdraw example.
Set the Forms KeyPreview Property to True.
Set the TabControls DrawMode Property to OwnerDrawFixed and add the code below to your form.

Assumes your Tabcontrol is named TabControl1.
TabControl using Custom TabPages.

This was one of the first projects I tackled in dotnet. The object was to have the tabpages support WindowsXP Visual Style. Adding visual style to an inherited TabPage was simple and after a few attempts I got the TabControl to accept the custom Tabpages via the Collection Editor.
Well since then I have learned a lot and I decided that I would rewrite the control. My goal this time was to get the DesignerVerbs to add the customised Tabpages as well as add an Insert verb. This turned out to be quite a challenge, since the TabControl Designer would not detect mouse clicks on any part of the control that was not a TabPage or TabItem. When I finally found the solution to this problem, as is usually the case, it was very simple to overcome. While I was at it I added an OnselectedIndexChanging event so that Tabpage changes may be cancelled, and a HotTab variable so you can check which tabitem the cursor is currently over. It would have been nice to add Mnemonic support, but that would involve taking full responsibility for painting the TabControl. If I'm going to do this then I may as well write the control from scratch.


Mirrored TabControl.

Enable the display of TabItems on your TabControl from RightToLeft.


Prevent users navigating TabControl via Ctrl+Tab and Ctrl+Shift+Tab.

Add the following code to your Form.


Add SelectedIndexChanging Event.

The following class adds a SelectedIndexChanging event to a TabControl. As well as dissallowing selection of a disabled tab via keyboard or mouse, you can now cancel a change of tabpage.

Does not include code to draw disabled tabs.
Add a HideTabs property to turn on/off the Tabs

I don't know why I didn't think to try this earlier. This also fixes the problem of tabpages not being displayed correctly when Alignment is set to anything other than Top and Appearance is not Normal. I have left the Border around the edge at 4 (when HideTabs is False), but you may wish to change this for the Button Appearance.