Windows Develop Bookmark and Share   
 index > Windows Forms General > OwnerDrawFixed TabPage in .NET 2.0
 

OwnerDrawFixed TabPage in .NET 2.0

Hi,

I'm wanting to use a bold font on some of my tabpage headers (the tabs themselved). Having searched the forums there is code that showns how to draw a disabled tabpage by using DrawMode = OwnerDrawFixed. I thought I could adapt this code but because my app is using XP visual styles I'm finding it hard to mimic the XP style tabs.

Does anyone now of a way to change just the font in .NET 2.0 tabpages?

Thanks for your help

Graham
Gravy  Friday, June 10, 2005 8:07 AM
Unfortunately this is a limitation of the underlying Win32 WC_TABCONTROL window class that the TabControl wraps.  The owner draw code in the Win32 control does not take the visual style scenaio into account.

 - mike
Mike Harsh  Tuesday, June 28, 2005 4:15 PM
I nearly got it working by using the VisualStyles namespace and OwnerDrawFixed but my problem now is the the bounding rectangle given in the DrawItem event args doesn't seem to include the hilight and lolight of the 3D tab item so when I use the VisualStyle renderer to draw the background it is slightly too small.

Who knows, I'm probably barking up the wrong tree with this!!

Hmm.

Graham
Gravy  Friday, June 10, 2005 10:24 AM
The TabControl supports a Font property.  You can change the font in the designer, and make it bold.  You can do this programmatically as follows:


tabControl1.Font = new Font(tabControl1.Font, tabControl1.Font.Style | FontStyle.Bold);


 


The TabControl.Font controls the font for the tabs themselves. The TabPage.Font controls the font for the page contents (inherited but overridable by the contained contents).

If you are looking to have different fonts for different tabs within one tab control, this would have to be done through owner-draw work.
durstin  Monday, June 13, 2005 6:48 PM
Thanks for the reply, but yes, I was after a different font on some tabs, but not all.

I thought that I would have to use OwnerDraw that's why I started looking at the VisualStyle classes. I got it to draw the outlook style tab but the problem I was left with was that the bounding rectangle I was given to draw in was too small, i.e. it automatically seemed to put a 3D border on the tabs - I need to draw my own border.

Graham
Gravy  Tuesday, June 14, 2005 8:11 AM
Unfortunately this is a limitation of the underlying Win32 WC_TABCONTROL window class that the TabControl wraps.  The owner draw code in the Win32 control does not take the visual style scenaio into account.

 - mike
Mike Harsh  Tuesday, June 28, 2005 4:15 PM

You can use google to search for other answers

Custom Search

More Threads

• Capture more webcam picture in one video file
• Cursor related with color
• ListView ColumnHeader resize Cursor
• Enter key on message box confused with enter key in form
• [drag&drop] determine explorer drop path
• Webbrowser Control used like windows Explorer - selected files
• Handling editing and updating in DataGridView
• How to add value to a speciffic column in listView?
• Drawing lines in C# on scrollable form
• Listbox across forms