What does ToolStripProfessionalRenderer.OnRenderItemBackground do?

830 views Asked by At

I am writing a custom ToolStripProfessionalRenderer component and currently working through all of the OnRender... overrides.

This one in particular has stumped me: OnRenderItemBackground

I can't see it drawing anything, so to force it to draw something I've done this:

protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e)
{
    e.Graphics.FillRectangle(Brushes.Red, e.Item.ContentRectangle);
}

...but I don't see any red rectangles, so not sure what it's doing!?

1

There are 1 answers

0
Hans Passant On BEST ANSWER

All the stock ToolStripItems you can add with the designer already render their own background. So what you draw with your OnRenderItemBackground() override is immediately over-painted again. So ProfessionalToolStripRender simply doesn't override the method since nothing needs to be done. The base class method, ToolStripRender.OnRenderItemBackground(), doesn't do anything either.

Note OnRenderButtonBackground(), OnRenderDropDownButtonBackground(), OnRenderLabelBackground(), etcetera.