Tab control problem in .net 1.1

04/09/2007 - 08:57 von naamala | Report spam
Hi,
I need to change individual tab's background color in TabControl
in windows form. I am able to change the Backgrond color of each tab
in TabControl with changing the property "DrawMode=OwnerDrawFixed".

The problem When I use "DrawMode=Normal", tabcontrol rendering the
background color of the form where there are no tabs, But When Change
"DrawMode=OwnerDrawFixed", it's not rendering Form's BackGround Color
where there are no tabs, It is displaying Color type of Control?

But I need to display the Background color of the Form where there
are no tab's;
How can I display the /paint it forms background color?


thanks
naamala
 

Lesen sie die antworten

#1 Robert-Reinhold Groß
04/09/2007 - 09:28 | Warnen spam
Hey Naamala,

this works at my project. Add these lines to the overriden TabControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
Region region = new Region( e.ClipRectangle );
for ( int i = 0; i < TabCount; i++)
{
Rectangle r = GetTabRect(i);
region.Exclude( r );
}
using (SolidBrush brush = new SolidBrush( _backcolor ))
{
e.Graphics.FillRegion( brush, region );
}
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground (pevent);
using (SolidBrush brush = new SolidBrush( _backcolor ))
{
pevent.Graphics.FillRectangle( brush,
pevent.ClipRectangle );
}
}

This fills the region next to Titles of each TabPage.

-Robert Groß.


naamala schrieb:
Hi,
I need to change individual tab's background color in TabControl
in windows form. I am able to change the Backgrond color of each tab
in TabControl with changing the property "DrawMode=OwnerDrawFixed".

The problem When I use "DrawMode=Normal", tabcontrol rendering the
background color of the form where there are no tabs, But When Change
"DrawMode=OwnerDrawFixed", it's not rendering Form's BackGround Color
where there are no tabs, It is displaying Color type of Control?

But I need to display the Background color of the Form where there
are no tab's;
How can I display the /paint it forms background color?


thanks
naamala

Ähnliche fragen