Mix 2010

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

When should I use a renderer and when should I just override OnPaint

Use draw from custom ToolStrip handler – which is the entry point into Renderer code. OnRender* will be called as a result. To change Renderer behavior, override OnRender*.

public class MyLabel : ToolStripLabel{
   protected override void OnPaint(PaintEventArgs e) {
    // Advantage here is that you'd get free disabled image support
    this.Parent.Renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(e.Graphics, this, this.Image, this.Bounds));
   }
}