Search code examples
c#.nettabcontrolownerdrawn

tabcontrol ownerdraw changes the tabcontrol's border style


I got a problem with tabcontrol. When I change the DrawMode to ownderdrawfixed, the borderstyle of the tabcontrol changes from "fixedsingle" to "3dfixed" but there's no such a property of tabcontrol borderstyle. the closest thing to borderstyle of tabcontrol is the appearance which didnt change.

alt text

look at the picture above to understand what I am talking about.

is there any way to change to color of the tabpage title without ownerdraw so I will not have to use ownerdraw?

or how can I fix the borderstyle of the tabcontrol?


Solution

  • When you set a control to ownerdraw, you are specifically saying "I will handle all drawing for this control". This disables the visual styles rendering completely.

    In order to render a control with visual styles, you'll need to use the facilities found in the System.Windows.Forms.VisualStyles namespace. It requires a good bit of code, but then you are saying you want to handle it all yourself. I'd start with the examples for VisualStyleRenderer - You'll need to call it, passing VisualStyleElements to render.

    See also this question about treeview ownerdraw: VisualStyleRenderer and themes (WinForms)