Home > Articles > Programming > User Interface (UI)

Designing GUI Applications with Windows Forms

Close Window

Erik RubinRonnie Yates 

Learn more…

Sorry, this author hasn't written any articles.

Sorry, this author doesn't have anything for sale.

Sorry, this author hasn't posted any blogs.

Microsoft .NET Compact Framework Kick Start

This chapter is from the book
Microsoft .NET Compact Framework Kick Start

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 Current Time Is",
  MessageBoxButtons.OK,
  MessageBoxIcon.Exclamation,
  MessageBoxDefaultButton.Button1)
End Sub

Figure 3.6 shows the GiveEmTime.exe running on the Pocket PC emulator. The button labeled What is the Time has been clicked, and the current time is being displayed in the dialog box.

Figure 3.6Figure 3.6 The GiveEmTime application running on the Pocket PC 2002 emulator.

Table 3.4 The KeyCodes Generated by the Directional Pad on a Pocket PC Device

KeyCode Value

Associated Hardware Button

Keys.Up

The top of the pad was pressed.

Keys.Down

The bottom of the pad was pressed.

Keys.Left

The left side of the pad was pressed.

Keys.Right

The right side of the pad was pressed.

Keys.Return

The center of the pad was pressed.


  • Share ThisShare This
  • Your Account

Discussions

error message
Posted Jun 19, 2008 07:53 AM by pandian602
0 Replies
dropdownlist
Posted Aug 30, 2007 08:23 AM by raghu_mrm
0 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Emily NaveCommunity Tips: Starting a User Group Library
By Emily Nave on August 3, 20102 Comments

The Central Penn Adobe User Group (CPAUG) uses a library program to share books from different publishers with members. A short Q&A with group leader Megan Fister provides some great tips for starting your own.

Keep going with GWT
By Federico Kereki on August 1, 2010 No Comments

I've been using GWT for some years now, and I'm still contented with the easier way for web development. After having written a book on GWT development, doing a blog seemed a good idea for answering questions, and for further expanding topics that didn't get a place in the book.

Emily NaveUser Group Organizations: Finding Support in the Greater IT Community
By Emily Nave on July 29, 20102 Comments

Birds of a feather flock together, right? If you’re already a member of an established user group or looking for other like-minded technology evangelists, connecting with peers is an important part of being an active voice in the IT community.

See All Related Blogs

Informit Network