changing BackColor of TabControl

  • Thread starter Thread starter Paiam Salavati
  • Start date Start date
P

Paiam Salavati

I have to change the BackColor of the unused part to the right of the tabs
in a TabControl.

therefore I have overriden the onPaint-Method of TabControl like this:

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);


Rectangle rectangle = new Rectangle(0, 0, this.Width, this.Height);

SolidBrush brush = new SolidBrush(Color.Blue)

e.Graphics.FillRectangle(brush, rectangle);

}




the problem is now, that the tabs in my TabControl are not visible anymore,
because they have also the color YellowGreen.

How can I set the backgroundcolor of my TabControl without covering the
tabs?


does anybody have some experience with that kind of problem?

Any help will be greatly appreciated....
 
Shouldn't you be calling base.OnPaint(e) AFTER you paint your rectangle?
Otherwise you're simply painting over what base.OnPaint() is painting.

Pete
 
Sorry, I sent that off without thinking. That's not going to work, I don't
believe because base.OnPaint will then probably paint over what you're
painting. Does changing the BackColor property not do what you need?

Pete
 
Back
Top