0

I know this tab draw item event in the link below will work fine on form load for all tabs and changes the tab header colors in tab control, but I am wondering how can I call/fire this event on a button click?. For example on form load it would be white and on button click it be red

Set TabPage Header Color

Community
  • 1
  • 1
CELLops
  • 13
  • 6

1 Answers1

2

The DrawItem event is fired when the Tab control is drawn. The drawing itself triggered by the area being "invalidated" (i.e. the graphics are no longer "valid" and need updating). This can be seen in the cited question's answer's code.

private void SetTabHeader(TabPage page, Color color)
{
    TabColors[page] = color;
    tabControl1.Invalidate();
}

The key method call here is "tabControl1.Invalidate();" it is this call that in turn triggers the drawing. Therefore you could either place similar code in the click event handler of your button, or simply call SetTabHeader if using that exact code sample.

MNB
  • 479
  • 6
  • 12