How to set the Background Coor for The Tabcontrol

V

vivek

Hi all...i need some clarification regarding setting
backcolor for Tabcontrol(Note:- Not for the
TabPage)...it's obvious there is no property for setting
back color of tabcontrol...so i used Graphics object to
acheive the tabcontrol backcolor.....using clear method
(one of the Graphic object method) i cleared the existing
surface of Tabcontrol and painting my own color..this has
been done successfully...whenever i choose the tabpage i'm
changing the font of choosen tab as bold and blue...this
i'm doing this by once again using clear method to paint
the tabcontrol with background and drawing the string and
setting the Forcolor an Border color(OutLine) ...thiese
things are happening as expected but there is a problem
when i move the mouse over the tabcontrol...whenever i
move the mouse cursor over tabcontrol the control
flickers ...did anyone came across these kind of
issues...do reply if u have any suggestions or
solutions ...below is my code which i used to acheive
setting back color for tabcontrol..

public form1()
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Blue);
Font font = new Font("Arial", 9.0f);
SolidBrush brush = new SolidBrush(Color.Blue);

Font v_objfont = new Font("Arial", 9.0f,FontStyle.Regular);
SolidBrush v_objBrush = new SolidBrush(Color.Black);

tabTextArea1 = (RectangleF)tab_scheduler.GetTabRect(0);
tabTextArea2 = (RectangleF)tab_scheduler.GetTabRect(1);
tabTextArea3 = (RectangleF)tab_scheduler.GetTabRect(2);

g.Clear(Color.PeachPuff);
g.DrawString("Add
Procedure",v_objfont,v_objBrush,tabTextArea1);
g.DrawString("Scheduler Report",font,brush,tabTextArea2);
g.DrawString("View All Report",font,brush,tabTextArea3);

g.DrawRectangle(p,tabArea1);
g.DrawRectangle(p,tabArea2);
g.DrawRectangle(p,tabArea3);
}


private void tab_scheduler_Click(object sender,
System.EventArgs e)
{
if(tabcontrol1.SelectedIndex==0)
{
tabcontrol1.DrawItem+=new DrawItemEventHandler
(DrawOnTab0_Click);
}
else if(tabcontrol1.SelectedIndex==1)
{
tabcontrol1.DrawItem+=new DrawItemEventHandler
(DrawOnTab1_Click);
}
else if(tabcontrol1.SelectedIndex==2)
{
tabcontrol1.DrawItem+=new DrawItemEventHandler
(DrawOnTab2_Click);
}
}

private void DrawOnTab0_Click(object sender,
DrawItemEventArgs e)
{
Graphics v_objGraphics0=e.Graphics;

Rectangle v_RectTab0 = (Rectangle)
tab_scheduler.GetTabRect(0);
Rectangle v_RectTab1 = (Rectangle)
tab_scheduler.GetTabRect(1);
Rectangle v_RectTab2 = (Rectangle)
tab_scheduler.GetTabRect(2);

v_objGraphics0.Clear(Color.Bisque);
Pen v_objPenTab0 = new Pen(Color.Blue);
Font v_objFontTab0 = new Font("Arial",
9.0f,FontStyle.Bold);
SolidBrush v_objBrushTab0 = new SolidBrush
(Color.Blue);

v_objGraphics0.DrawRectangle
(v_objPenTab0,v_RectTab0);
v_objGraphics0.DrawString("Add
Procedure",v_objFontTab0,v_objBrushTab0,v_RectTab0);

Pen v_objPenTabs = new Pen(Color.Blue);
Font v_objFontTabs = new Font("Arial",
9.0f,FontStyle.Regular);
SolidBrush v_objBrush = new SolidBrush
(Color.Black);

v_objGraphics0.DrawRectangle
(v_objPenTabs,v_RectTab1);
v_objGraphics0.DrawString("Scheduler
Report",v_objFontTabs,v_objBrush,v_RectTab1);

v_objGraphics0.DrawRectangle
(v_objPenTabs,v_RectTab2);
v_objGraphics0.DrawString("View All
Report",v_objFontTabs,v_objBrush,v_RectTab2);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top