Paint one forms with two paint event handler : Form Event : GUI Windows Forms C# Examples


C# Examples » GUI Windows Forms » Form Event »

 

Paint one forms with two paint event handler









    
using  System;
using  System.Drawing;
using  System.Windows.Forms;
      
class  TwoPaintHandlers
{
          public  static  void  Main()
          {
                    Form  form            =  new  Form();
                    form.Text            =  "Two  Paint  Handlers";
                    form.BackColor  =  Color.White;
                    form.Paint        +=  new  PaintEventHandler(PaintHandler1);
                    form.Paint        +=  new  PaintEventHandler(PaintHandler2);
      
                    Application.Run(form);
          }
          static  void  PaintHandler1(object  objSender,  PaintEventArgs  pea)
          {
                    Form          form  =  (Form)objSender;
                    Graphics  graphics  =  pea.Graphics;
      
                    graphics.DrawString("First  Paint  Event  Handler",  form.Font,  
                                                    Brushes.Black,  0,  0);
          }
          static  void  PaintHandler2(object  objSender,  PaintEventArgs  pea)
          {
                    Form          form  =  (Form)objSender;
                    Graphics  graphics  =  pea.Graphics;
      
                    graphics.DrawString("Second  Paint  Event  Handler",  form.Font,  
                                                    Brushes.Black,  0,  100);
          }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo GUI Windows Forms
» Form Event