473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problems with the display of the tabs in my customized TabControl

I want to change the the color of the tabs and the color of TabControl
itself in a TabControl. Therefore I wrote the following code in my
customized TabControl-class:

this.DrawMode = TabDrawMode.OwnerDrawFixed;

protected override void OnDrawItem(DrawItemEventArgs e)

{

e.Graphics.FillRectangle(new SolidBrush(Color.Gray), this.ClientRectangle);

for(int i = 0; i < this.TabCount; i++)

{
Rectangle currentPage = this.GetTabRect(i);

e.Graphics.FillRectangle(new SolidBrush(Color.Green), currentPage);

e.Graphics.DrawString(this.TabPages[i].Text, e.Font, new
SolidBrush(mTabFontColor), currentPage, StringFormat.GenericDefault);

}
}

It changes the colors correct, but the problem is, that the tabs aren't
shown correct (especially if appearence = Button is selected, than it
sometimes draws a normal rectangle instead of an unselected button ).

Does anybody have an idea how I could change the color of the tabs and also
the color of the tabControl itself in a proper way?

I know about "dotnetmagics", but I am not willed to purchase it, because I
think there has to be a different way of implementing this comparative
simple task.

Jul 21 '05 #1
1 1958
Instead of setting OwnerDrawFixed, I set the following style upon
initialization.
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer |
ControlStyles.UserPaint,true);

This results in a fully ownerdraw Tabcontrol instaed of the partially
ownerdraw style offered by the control itself.
The main disadvantage here is that it is entirely up to you to paint every
part of the control, but the main advantage is that it is entirely up to you
how you draw each part of the control ;-)

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi100/index.html
"Paiam Salavati" <pa************@skillworks.de> wrote in message
news:2i************@uni-berlin.de...
I want to change the the color of the tabs and the color of TabControl
itself in a TabControl. Therefore I wrote the following code in my
customized TabControl-class:

this.DrawMode = TabDrawMode.OwnerDrawFixed;

protected override void OnDrawItem(DrawItemEventArgs e)

{

e.Graphics.FillRectangle(new SolidBrush(Color.Gray), this.ClientRectangle);
for(int i = 0; i < this.TabCount; i++)

{
Rectangle currentPage = this.GetTabRect(i);

e.Graphics.FillRectangle(new SolidBrush(Color.Green), currentPage);

e.Graphics.DrawString(this.TabPages[i].Text, e.Font, new
SolidBrush(mTabFontColor), currentPage, StringFormat.GenericDefault);

}
}

It changes the colors correct, but the problem is, that the tabs aren't
shown correct (especially if appearence = Button is selected, than it
sometimes draws a normal rectangle instead of an unselected button ).

Does anybody have an idea how I could change the color of the tabs and also the color of the tabControl itself in a proper way?

I know about "dotnetmagics", but I am not willed to purchase it, because I
think there has to be a different way of implementing this comparative
simple task.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rossum | last post by:
I have a TabControl with a lot of tabs in it. Since it is sometimes difficult to tell which tab is currently active (all the pages have the same layout) I want to be able to highlight which tab is...
4
by: Randy | last post by:
I'm writing an application where the user interface has many tabs, and sets of tabs within each tab (customer requirement). Each subtab has a great number of it's own controls and functions. Rather...
4
by: Alberto | last post by:
How can I do to show the tabs in a TabControl in the botton of the control? Thank you.
1
by: Paiam Salavati | last post by:
I want to change the the color of the tabs and the color of TabControl itself in a TabControl. Therefore I wrote the following code in my customized TabControl-class: this.DrawMode =...
2
by: michael sorens | last post by:
After extensive searching of the docs, I find no mention of support for Ctrl-Tab and Ctrl-Shift-Tab to navigate among tabs in a TabControl. I am surprised that such a common/standard keyboard...
3
by: Jean Paul Mertens | last post by:
Hello, Is there a way to change the background color of the tabs in a tabcontrol (there where the name of the tab is and where you click to change to an other tab) I don't see any property or...
0
by: samadams_2006 | last post by:
Hello, I have a VB.NET Form which has a System.Windows.Forms.TabControl on it. This TabControl has 5 Tabs on it. On each tab, I have various textboxes, option boxes, radio boxes, etc. I would...
4
by: hariadusumalli | last post by:
Hi, I added a tab control to my form. I need to add the tab pages to the control at run-time. But this is little different from the normal way. I need to display one specific tab to the right...
7
by: roundcrisis | last post by:
Well basically i need to have a tab control but not show the actual tabs how to? there doesnt seem to be any property to do this either in teh tab control nor in each tab Cheers
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.