Programming the Button Control

The System.Windows.Forms.Button class is the .NET implementation of a button control. When the user clicks the button with the stylus, a Click event is raised. You can handle this event by implementing a System.EventHandler delegate. The code that follows is an implementation of the EventHandler that displays the current time.

 C# Private void button_Click(object sender, System.EventArgs e) { MessageBox.Show(DateTime.Now.ToShortTimeString(), "The Current Time Is", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } VB Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show(DateTime.Now.ToShortTimeString(), "The ...

Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.