Previous Page
Next Page

Chapter 20 Quick Reference

To

Do this

Create a Windows Forms project.

Use the Windows Application template.

Change the properties of a form.

Click the form in Design View. In the Properties window, select the property you want to change and enter the new value.

View the code behind a form.

On the View menu, click Code.

Add controls to a form.

Drag the control from the Toolbox onto the form.

Change the properties of a control.

While in Design View, click the control. In the Properties window, select the property you want to change and enter the new value.

Dynamically populate a ComboBox or a ListBox.

Use the Add method of the Items property. For example:

towerNames.Items.Add("Upper Gumtree");

You might need to clear the Items property first, depending on whether you want to retain the existing contents of the list. For example:

towerNames.Items.Clear();

Initialize a CheckBox or radio button.

Set the Checked property to true or false. For example:

novice.Checked = true;

Handle an event for a control or form.

Select the control or form in Design View. In the Properties window, click the Events button. Find the event you want to handle and type the name of an event method. Write the code that handles the event in the event method.


Previous Page
Next Page