 |
|
|
 |
|
 |
Thanks for the article. This was very informative. I had come across several articles like this to help with this problem.
My situation required letting the BackgroundImage of the form show through the end of the TabStrip after the tabs (instead of the standard gray) as well as using images on the tabs. I had to add my own solution, which I documented on our company blog: http://blog.villainousmind.com/2009/04/fix-backcolor-for-tabcontrol-in-net.html[^]
I hope this helps anyone who was in my situation.
|
|
|
|
 |
|
 |
when change the properties( RightToLeftLayout to true and RightToLeft to yes ) the color of tap page appear in left not on right.
Is it bug ?? because the bound when tracing come on left not on right.
any one can know what can we do to make it work write.
-- modified at 2:11 Saturday 29th September, 2007
|
|
|
|
 |
|
 |
TabPage tp = this.tabControl1.TabPages[e.Index];
And then set the brush using the actual tab page:
brushSelected = new SolidBrush(tp.BackColor)
|
|
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under
|
|
|
|
 |
|
 |
I've created a .Net 2.0 toolbox ColorTabControl from your code.
I've added 3 properties to the base TabControl: InactiveColorOn, InactiveFGColor, InactiveBGColor.
Setting the ColorTabControl.Font to Bold will cause the selected Tab to be Bold. The unselected tabs are never bold. An additional property could manage that as well. Maybe an InactiveTabFont.
Setting InactiveColorOn=false will cause the unselected tabs to display the colors of their indiviual pages.
Once the DLL is built and registered in the Global Assembly Cache, the developer only needs to select it in Choose Toolbox Items.
They may need to create a registry path to the DLL for Visual Studio.
e.g.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\ColorTabControl]
@="C:\\ColorTabControl\\bin\\Release"
I didn't want to publish a new article since I used your code to build it.
Maybe you could update your article or add an addendum.
Is there a way for me to send the source to you without posting my email address publicly? Otherwise, I could just go ahead and post a new article.
Alan Gerber
|
|
|
|
 |
|
 |
You can mail me at sreejithssnair@hotmail.com and will send an update. Thanks
|
|
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under
|
|
|
|
 |
|
 |
The BackColor property of the event arg e isn't the same as the property page that you are trying to get the BackColor Property From. To fix this use the following: TabPage tp = this.tabControl1.TabPages[e.Index]; And then set the brush using the actual tab page: brushSelected = new SolidBrush(tp.BackColor)
|
|
|
|
 |
|
 |
Thanks and will update in upcomming release.
|
|
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under
|
|
|
|
 |
|
 |
dear friend,
this article helped me in getting my tab control coloured. The prperty which Microsoft hasn't provided. But when the call to redraw method is made, the whole tab blinks, and this blinking (many times) for each page gives awful look.
Asher
|
|
|
|
 |
|
 |
You can implement DoubleBuffering in your application. This will surely serve your purpose.
|
|
|
|
 |
|
 |
Thanks for replying.
I have used...
SetStyle( ControlStyles.Doublebuffered | ControlStyles.AllPaintingInWmPaint, true );
for double buffering in main_Load
But redrawing of pages is still apparent
I am still searching what should i do.... as i need to change the color and can't afford this flickering.
asher
|
|
|
|
 |
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under Custom Tab Control[^]
|
|
|
|
 |
|
 |
Hi,
Great code...it's better than lots of examples I have seen out there.
However, can you give us a hand with filling in the rest of the tab control colors?
With your code I'm able to set the tab control buttons correctly, however the rest of the control still uses the system grey.
//Thsi will help you to fill the interior portion of
//selected tabpage.
e.Graphics.FillRectangle(backBrush, e.Bounds);
Rectangle r = e.Bounds;
r = new Rectangle(r.X, r.Y + 3, r.Width, r.Height - 3);
e.Graphics.DrawString(tabName, f, foreBrush, r, sf);
//I tried adding this line of code, and get an interesting result....
e.Graphics.FillRectangle(backBrush,this.tabControl1.Bounds );
|
|
|
|
 |
|
 |
I tried this and it worked:
e.Graphics.FillRectangle(backBrush, 0, 0, tabControl1.Width, tabControl1.Height);
add this line before
string tabName = tabControl1.TabPages[e.Index].Text;
Hope it's what you were looking for!
Best regards,
Balder
|
|
|
|
 |
|
 |
I too added this line of code. In that case, the whole thing gets colored. I'm not able to view the non selected tabs
|
|
|
|
 |
|
 |
Adding tis code at the beginning of the DrawItem function made it work.....
Rectangle tabRect = tabControl1.Bounds;
Region tabRegion = new Region( tabRect );
Rectangle TabItemRect = new Rectangle(0, 0, 0, 0);
for (int nTanIndex = 0; nTanIndex < tabControl1.TabCount; nTanIndex++)
{
TabItemRect = Rectangle.Union(TabItemRect, tabControl1.GetTabRect(nTanIndex));
}
tabRegion.Exclude(TabItemRect);
Brush BackBrush = new System.Drawing.SolidBrush(Color.DarkGray);
e.Graphics.FillRegion(BackBrush, tabRegion);
Hope this will work
Thanks
Rohini
|
|
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under Custom Tab Control[^]
|
|
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under Custom Tab Control[^]
|
|
|
|
 |
|
 |
Hi!
Is it possible to derive a class from TabPage (e. g. MyTabPage) and put your code into the right method of MyTabPage? So I wouldn't need to 'ownerdraw' the TabPages and the MyTabPage could be handled like a normal TabPage.
Greetings
Falk
|
|
|
|
 |
|
|
 |
|
 |
Hi,
Once again thanks for your interest and support shown for this article. You can find a revised version of the this article under Custom Tab Control[^]
|
|
|
|
 |