I have one tab control with 5 tab pages.
I want to color each tab page a different color.
Does anyone know how to color the entire tab page a unique color?
(that includes the tab part of the tab page)
In other words, just like different paper folders come in different colors,
how do you program this?
If you look at the code I got from Microsoft, this will color only one tab
and put text on only one tab:
HOw does one do it when you have 5 tab pages with one tab control?
tabControl1.Dra wMode = TabDrawMode.Own erDrawFixed;
....
....
tabControl1.Dra wItem += new DrawItemEventHa ndler(DrawOnTab );
....
....
private void DrawOnTab(objec t sender, DrawItemEventAr gs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Blue) ;
Font font = new Font("Arial", 10.0f);
SolidBrush brush = new SolidBrush(Colo r.Red);
SolidBrush brush1 = new
SolidBrush(Colo r.Beige);
g.DrawRectangle (p, tabArea);
g.DrawString("t abPage1",font,b rush,tabTextAre a);
} 4 8823
got an ugly one, hope it's helpful:
------------------------------------------------------
private void DrawOnTab(objec t sender, DrawItemEventAr gs e)
{
if (e.State == DrawItemState.S elected)
{
TabControl tc = (TabControl) sender;
TabPage currentTab = tc.TabPages[tc.SelectedInde x];
Graphics g = e.Graphics;
Font font = new Font("Arial", 10.0f);
SolidBrush brushRed = new SolidBrush(Colo r.Red);
Color[] backColors = new Color[3]{Color.Blue,
Color.Green, Color.Black};
Rectangle tabArea = e.Bounds;
Rectangle tabTextArea = e.Bounds;
Brush backBrush = new
SolidBrush(back Colors[tc.SelectedInde x]);
g.FillRectangle (backBrush, tabArea);
currentTab.Back Color = backColors[tc.SelectedInde x];
g.DrawString(cu rrentTab.Text, font, brushRed,
tabTextArea);
}
}
private void tabControl1_Sel ectedIndexChang ed(object sender,
System.EventArg s e)
{
tabControl1.Inv alidate();
}
You'll find several tips on modifying TabControl on my site. http://dotnetrix.co.uk/tabcontrols.html
You'll also find TabControlEX which has already got these features built in. http://dotnetrix.co.uk/controls.html --> TabControlEX
--
Mick Doherty http://dotnetrix.co.uk/nothing.html
"Martha" <Ma****@discuss ions.microsoft. com> wrote in message
news:20******** *************** ***********@mic rosoft.com... I have one tab control with 5 tab pages. I want to color each tab page a different color. Does anyone know how to color the entire tab page a unique color? (that includes the tab part of the tab page) In other words, just like different paper folders come in different colors, how do you program this?
If you look at the code I got from Microsoft, this will color only one tab and put text on only one tab: HOw does one do it when you have 5 tab pages with one tab control?
tabControl1.Dra wMode = TabDrawMode.Own erDrawFixed; ... ...
tabControl1.Dra wItem += new DrawItemEventHa ndler(DrawOnTab ); ... ... private void DrawOnTab(objec t sender, DrawItemEventAr gs e) { Graphics g = e.Graphics; Pen p = new Pen(Color.Blue) ; Font font = new Font("Arial", 10.0f); SolidBrush brush = new SolidBrush(Colo r.Red); SolidBrush brush1 = new SolidBrush(Colo r.Beige); g.DrawRectangle (p, tabArea); g.DrawString("t abPage1",font,b rush,tabTextAre a); }
realfun almost has a perfect solution, however the non active tabs turned to
grey color instead of keeping their color. In other words, the only tab that
has the right color is the active tab (one just clicked) Any ideas on how to
fix it?
Martha
"re*****@gmail. com" wrote: got an ugly one, hope it's helpful: ------------------------------------------------------ private void DrawOnTab(objec t sender, DrawItemEventAr gs e) { if (e.State == DrawItemState.S elected) { TabControl tc = (TabControl) sender; TabPage currentTab = tc.TabPages[tc.SelectedInde x]; Graphics g = e.Graphics; Font font = new Font("Arial", 10.0f); SolidBrush brushRed = new SolidBrush(Colo r.Red); Color[] backColors = new Color[3]{Color.Blue, Color.Green, Color.Black}; Rectangle tabArea = e.Bounds; Rectangle tabTextArea = e.Bounds; Brush backBrush = new SolidBrush(back Colors[tc.SelectedInde x]); g.FillRectangle (backBrush, tabArea); currentTab.Back Color = backColors[tc.SelectedInde x]; g.DrawString(cu rrentTab.Text, font, brushRed, tabTextArea); } }
private void tabControl1_Sel ectedIndexChang ed(object sender, System.EventArg s e) { tabControl1.Inv alidate(); }
I suggest you follow Mick's link, it solves your problem from lap to
top. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lars Behrmann |
last post by:
Hi,
i have an ActiveX control placed on my windowsform.
Visual Studio has wrapped this and everything should
be fine, but it isn't :( The control shows different
behaviours between the Visual Studio Designer and
the compiled app. The ActiveX control works as a
container for documents so it can load and close
these documents. In the designer it works, but in
the compiled app it doesn't!? Instead of closing
|
by: Alessandro |
last post by:
There is a way to give different color to listitems of a ListBox ?
|
by: TJS |
last post by:
I am populating a dropdownlist control from a query. Each line of content
in the dropdownlist may get modified with a leading text character as a flag
before being added to the list.
how can I modify a leading character to be in a different color or perhaps
add a small leading image to indicate the flag ?
|
by: Mamatha |
last post by:
Hi
I have one application in VB.NET using the concept of
mutithreading.In that application when we click on one
button some will be displayed by the threads in the
listbox.Actually i downloaded this code,Now i want to
change that data into datagrid.But while i am trying to
display data in datagrid it gives error like "controls
create on one thread cannot be parented to a control on
different thread".How can i shift my data from listbox...
|
by: ad |
last post by:
I set a row of gridview different color when one value in the first column
if greater the the value in the second column.
How can I do?
| |
by: ad |
last post by:
I want to show the background color of a row in a gridview to different
color when the value of a column is greater than 100.
How can I do?
|
by: bb nicole |
last post by:
Below is css for the link color for my homepage... My homepage have 5 different table which contain a link... If i wish to have different color for the link in different table in same page, what coding i should adding?? Can someone give me a guildeline?? Thanks..
<style type="text/css">
<!--
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
|
by: Simon |
last post by:
By default, days in the calendar control are simply displayed as numbers, I
want to show some days in a different color in this control. What is the
best way to do that?
Thanks very much.
|
by: JB |
last post by:
Hi All,
I have a DataGridView in which some columns are combo boxes (i.e.
DataGridViewComboBoxColumn). I populate these Combo Boxes directly by
using code like this:
Dim NewCol As New System.Windows.Forms.DataGridViewComboBoxColumn
NewCol.Items.Add("Item 1")
NewCol.Items.Add("Item 2")
NewCol.Items.Add("Item 3")
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |