Cast event sender to a control : Message : Event C# Source Code


Custom Search

C# Source Code » Event » Message »

 

Cast event sender to a control








    
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class InstantiateHelloWorld
{
     public static void Main()
     {
          Form form   = new Form();
          form.Text   = "Instantiate " + form.Text;
          form.Paint += new PaintEventHandler(MyPaintHandler);
   
          Application.Run(form);
     }
     static void MyPaintHandler(object objSender, PaintEventArgs pea)
     {
          Form     form = (Form)objSender;
          Graphics graphics = pea.Graphics;
   
          graphics.DrawString("Hello from InstantiateHelloWorld!", 
                          form.Font, Brushes.Black, 0, 100);
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Event
» Message