Problem while setting the backcolor for TabControl

  • Thread starter Thread starter Vivek
  • Start date Start date
V

Vivek

Hi all...i need some clarification regarding setting
backcolor for Tabcontrol(not the tab pages)...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 coding which i used to acheive
setting the backcolor 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);
} }

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

......
......
......
doing as like DrawOnTab0_click event...here i change the
font of tab1 string to bold and color to Black and rest
of string in tab2 and tab0 to regular...
 
Back
Top