Setting Up Base Functionality

Visual Studio allows you to build your application forms by selecting UI components in the Toolbox pane on the left and dragging them onto the form in the Design view. To make your application easier to work with, you should change the names of your UI components from the standard label1, label2...label37 to something more recognizable.

Add a Button to the View

From the Toolbox pane on the left, select a button and drag it onto the form (Figure 5-3).

Figure 5-3. Selecting a button from the toolbox pane

Customize the Button

Click the button on your form once, and in the Properties pane under Appearance, change the label in the text field to "Submit," as shown in Figure 5-4. Then, under Design, set the name of the button to "submitButton," as shown in Figure 5-5.

Figure 5-4. Changing the label in the text Held to "Submit"
Figure 5-5. Setting the name of the button to "submitButton"

Create a Click Event Handler

Back in the design view, double-click the button you just created. This opens Form1.cs and generates an empty handler in the Form1.cs file (Figure 5-6).

Figure 5-6. The Form1.cs file

In the handler, type the following line of code: submitButton.Text = "Clicked";

Was this article helpful?

0 0
Living With Android

Living With Android

Get All The Support And Guidance You Need To Finally Be A Success At Using Android. This Book Is One Of The Most Valuable Resources In The World When It Comes To Playing With the Hottest Android Tablet.

Get My Free Ebook


Post a comment