views:

34

answers:

1

Hi,

I want to use a tab control and have the tabs displayed on the left, as opposed to at the top. I have set the alignment to the left and the tabs are displayed there. However, how do I get the text to be displayed on the tab, vertically? I have looked at the msdn and it gives an example of a left aligned tab control but the tab label is still displayed horisontally!

The other thing, does anybody know how to use the tab control with left aligned tabs with the default layout so that it looks better?

Please no third party apps unless they are free, and yes I have looked at code project already.

Thanks, R.

A: 

It is an age-old bug in the visual styles renderer for the native Windows tab control. It only supports tabs at the top, the Microsoft programmer that worked on it was run over by a bus before she could finish the job, I guess.

The only thing you can do about it is selectively turn off visual styles for the control. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form, replacing the original.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class FixedTabControl : TabControl {
    [DllImportAttribute("uxtheme.dll")]
    private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);

    protected override void OnHandleCreated(EventArgs e) {
        SetWindowTheme(this.Handle, "", "");
        base.OnHandleCreated(e);
    }
}
Hans Passant
Awesome. Now I just need to restyle it... :)
flavour404
I could comment on that, but then my answer might accidentally be helpful.
Hans Passant
Hans, could you please be helpful and tell me how to restyle it? I would like to make it look like the default tab control. Any advice help would be grateful as this stuff is new and I feel like I am going around in circles, or google circles anyway...
flavour404