How do I show Tab control on my form in Win XP style Look? i have set the Drawmode=OwnerDrawFixed while Xp Style Look is disappere in vs.net2005. I tried to use Application.EnableVisualStyles but that doesn't change in Tab Control.
i have used Skybound Component through that i can achive it but my requirement is not used any thried party control. so without use any thried party i need to get the XP Style Look in Tab control.

if any one know then please let me know....................

Dani AI

Generated

Short answer: setting DrawMode = OwnerDrawFixed hands painting to your code, so the control no longer uses the OS theme. That is why Application.EnableVisualStyles or an application manifest (as mentioned) will style standard tabs but will not restore the XP look for an owner-drawn TabControl. correctly moved to a custom-drawn solution; to keep the XP (or current OS) appearance you must paint the themed parts yourself.

If you want themed rendering while still owner-drawing, use VisualStyleRenderer to draw the tab background/edges and then draw the text. Example (VB.NET) inside TabControl.DrawItem:

Imports System.Windows.Forms.VisualStyles

Private Sub TabControl1_DrawItem(sender As Object, e As DrawItemEventArgs) Handles TabControl1.DrawItem
    Dim bounds = TabControl1.GetTabRect(e.Index)
    If VisualStyleRenderer.IsElementDefined(VisualStyleElement.Tab.TabItem.Normal) Then
        Dim r As New VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal)
        r.DrawBackground(e.Graphics, bounds)
    Else
        e.Graphics.FillRectangle(SystemBrushes.Control, bounds)
    End If
    TextRenderer.DrawText(e.Graphics, TabControl1.TabPages(e.Index).Text, TabControl1.Font, bounds, SystemColors.ControlText, TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter)
End Sub

References: VisualStyleRenderer and the Tab visual elements are documented by Microsoft: and .

For the redraw/performance problem when many controls live on pages: avoid recreating controls on each tab change, call SuspendLayout/ResumeLayout while adding or showing groups of controls, and enable double buffering on the container (derive a TabPage or Panel and call SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)). For bulk updates you can temporarily disable repaint with WM_SETREDRAW and then re-enable and Refresh(); see the double-buffering guidance here: and WM_SETREDRAW docs: .

If the goal is an exact XP Luna look on newer OSes, that requires drawing Luna-specific art (or shipping themed assets). For forcing a specific OS theme at control level, SetWindowTheme exists but is a native tweak and should be used carefully: SetWindowTheme.

Recommended Answers

All 2 Replies

hi,

You can use manifest file to take the style from the current operating system.
I dont know which version of VB.NET you wroking with , but this way worked good with 2002,2003 and it is so easy to apply
Just rename the attached file , the first section of it "AppName" replace with your Application exe Name, then put this file in the bin folder of your application.

in the Form Design you have to change one Property for buttons :
FlatStyle , change to System and Run with XP themes

Remember that when you finishing the application , you have to include the manifest file in the setup project

Good Luck

Thanks Ammar.

I have tried out manifest file in my app. But that is not working.

By the way I’m using visual studio 2005, it provides all the controls looks like xp style so that manifest feature is inbuilt in framework 2.0. But the only one problem in “Tab Control

Well finally I have got the solution and I had created one article in codeproject.

Here is the link http://www.codeproject.com/useritems/Pankaj_Patel.asp

I have faced one problem in this Tab control article. When I’m putting 10 to 15 controls on each tab and then navigate between them, I have noticed a considerable delay in redrawing the controls on the TAB Page

So if you have any idea then pls let me know…

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.