Database Reference
In-Depth Information
12. Save the changes in your project by clicking File Save All.
How It Works
When you resize the form, it will behave according to the settings of the Dock and Anchor properties.
In the first instance, you set the Dock property of the Label control to Top, which allows this Label
control to be affixed to the top border of the form and span the entire width of the form. Setting the
Anchor property of the remaining controls to Top, Left, and Right shifts the controls in such a manner
that they will maintain a constant distance from the left and right borders of the form.
Adding a New Form to the Project
Any real-world or enterprise application will obviously need multiple Windows forms to perform
business functionality. By default, every project opens with only one Windows form, but you are free to
add more.
Try It: Adding a New Form to the Windows Project
In this exercise, you will add another Windows form to your project. You will also work with ListBox,
ComboBox, RadioButton, and CheckBox controls. In this new form, you will add data from two different
text boxes to a ListBox and a ComboBox, respectively.
1. Navigate to Solution Explorer and select the WinApp project, right-click, and
click Add Windows form. This will add a new Windows form in your project.
2. In the Add New Item dialog box displayed, change the form's name from
Form1.cs to UserInfo.cs . Click Add. The new form with the name UserInfo will
be added to your project.
3. Ensure that the newly added form UserInfo is open in the Design view. Select
the UserInfo form by clicking the form's titlebar, navigate to the Properties
window, and set the Size property's Width to 455 and Height to 251.
4. Drag a Label control onto the form; select this control, navigate to the
Properties window, and set the following properties:
a. Set the Name property to lblCountry.
b. Set the AutoSize property to false.
c. Set the Location property's X to 12 and Y to 26.
d. Set the Size property's Width to 71 and Height to 13.
e. Set the Text property to Enter Country.
5. Drag a TextBox control in front of the lblCountry label. Select this control,
navigate to the Properties window, and set the following properties:
a. Set the Name property to txtCountry.
b. Set the Location property's X to 97 and Y to 19.
 
Search WWH ::




Custom Search