Welcome to WindowsClient.net | Sign in | Join

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

Windows Forms FAQs

How do I add custom drawing to a Button?

Subclass Button and add a custom Paint event handler that does you custom drawing.

public class CustomButton : Button
{
  public CustomButton()
  {
    Paint += new PaintEventHandler( ButtonPaint );
  }

  private void ButtonPaint( object sender, PaintEventArgs e )
  {
    Pen pen = new Pen( Color.Red );
    pen.Width = 8;
    e.Graphics.DrawLine( pen, 7, 4, 7, Height - 4 );
    pen.Width = 1;
    e.Graphics.DrawEllipse( pen, Width - 16 , 6, 8, 8 );
  }
}

Contributed from George Shepherd's Windows Forms FAQ