View Single Post
Old 03-08-2009, 04:28 PM   #3 (permalink)
connyosis
Psycho
 
connyosis's Avatar
 
Location: Sweden - Land of the sodomite damned
Here is a very simple example:

Code:
using System;
using System.Windows.Forms;
using System.Drawing;
	
public class MyEventHandler : Form
{		
	public MyEventHandler()
	{
		// Just setup a very very simple UI
		Size = new Size(200, 200); // Size of window
		
		// Create new button with the created window as parent
		Button myButton = new Button();
		myButton.Parent = this;
		myButton.Text = "Click me";
		// When button is clicked, run OnButtonClick
		myButton.Click += new EventHandler(OnButtonClick);
	}
	
	// Display message box when button has been clicked
	public void OnButtonClick(object sender, EventArgs e)
	{
		MessageBox.Show("You clicked me");
	}
	
	public static void Main()
	{
		Application.Run(new MyEventHandler());
	}
}
__________________
If atheism is a religion, then not collecting stamps is a hobby.
connyosis is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54