Override Paint method for Form : Form Paint « GUI Windows Forms « C# / CSharp Tutorial






Override Paint method for Form
using System;
using System.Drawing;
using System.Windows.Forms;

public class FormPaintOverride : Form
{

  public FormPaintOverride()
  {
        Text = "Paint Demonstration";
    Size = new Size(300,200);
  }

  static void Main() 
  {
    Application.Run(new FormPaintOverride());
  }

  protected override void OnPaint(PaintEventArgs e)
  {
    base.OnPaint(e);
    Graphics g = e.Graphics;
    g.DrawString("www.java2s.com", Font, Brushes.Black, 50, 75);
  }
}








23.4.Form Paint
23.4.1.FormPaint EventFormPaint Event
23.4.2.Override Paint method for FormOverride Paint method for Form
23.4.3.Paint Invalidate DemonstrationPaint Invalidate Demonstration