Handle button messages : Button : GUI Windows Forms C# Examples


C# Examples » GUI Windows Forms » Button »

 

Handle button messages









    
using  System;  
using  System.Windows.Forms;  
using  System.Drawing;  
  
class  ButtonEventForm  :  Form  {  
    Button  MyButton  =  new  Button();  
  
    public  ButtonEventForm()  {  
        Text  =  "Respond  to  a  Button";  
  
        MyButton  =  new  Button();  
        MyButton.Text  =  "Press  Here";  
        MyButton.Location  =  new  Point(100,  200);  
  
        //  Add  button  event  handler  to  list.  
        MyButton.Click  +=  MyButtonClick;  
  
        Controls.Add(MyButton);  
    }      
  
    [STAThread]  
    public  static  void  Main()  {  
        ButtonEventForm  skel  =  new  ButtonEventForm();  
  
        Application.Run(skel);  
    }  
  
    //  Handler  for  MyButton.  
    protected  void  MyButtonClick(object  who,  EventArgs  e)  {  
        Console.WriteLine("action.");
  
    }  
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo GUI Windows Forms
» Button