P
Paiam Salavati
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.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.
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.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.