
In this tutorial we are going to start finding out more about the toolbox we utilized in the previous tutorial. *The Controls available in the toolbox are quite extensive and allow users to simplify a variety of everyday tasks such as manually creating and instantiating a textbox on a windows form. *At the end of this tutorial you should be comfortable finding Controls in the Visual Studio Toolbox, alter or produce code to link tools together using event handlers and ultimately get a better sense of Visual Studio, it’s layout and how to easily navigate it.
<div style="text-align:left;">To start we are going to create a new Windows Forms Application project in a new solution that will be called ApplicantRegistration. *After the project is created we need to change the name of the form from Form1 to main and change the name on the top of the form to Applicant Registration under text in the Properties tab. *Then we can start adding in labels and changing Text and Name Properties for:
- First Name (Text: First Name, Name: lblFirstName)
- Last Name (Text: Last Name, Name: lblLastName)
- Address (Text: Address, Name: lblAddress)
- City (Text: City, Name: lblCity)
- Zip Code (Text: Zip Code, Name: lblZipCode)
- Email Address (Text: Email Address, Name: lblEmail)
- Phone Number (Text: Phone Number, Name: lblPhone)
- First Name (Name: txtFirstName)
- Last Name (Name: txtLastName)
- Address (Name: txtAddress)
- City (Name: txtCity)
- Zip Code (Name: txtZipCode)
- Email Address (Name: txtEmail)
- Phone Number (Name: txtPhone)

We now want to add the button that we are going to utilize to enter the forms data into a storage container. *We need to drag the button from the toolbox onto the form and change the Text to “Submit” and the name to btnSubmit. *After this is done we can double click on the button which will take us to the code that will be utilized when the user clicks the button. *To do this we are going to start out by clearing all of the form data so when the user presses submit the boxes clear and are ready for another entry. *To do this our code will look like something along the lines of:
private void btnSubmit_Click(object sender, EventArgs e)
{
txtFirstName.Text = "";
txtLastName.Text = "";
txtAddress.Text = "";
txtCity.Text = "";
txtZipCode.Text = "";
txtEmail.Text = "";
txtPhone.Text = "";
}
After the code for the button is made we want to extend the *form to the right and add some controls for birth-date and gender. *We will start by making labels for Birthday and Gender respectively. *After we have created the two labels we are going to drag three combo boxes onto the form, one for the day, month and year. *When renaming objects on forms I tend to shorten what the object is into a minimum of two letters and a maximum of four. *The final result would be cbYear, cbMonth and cbDay respectively. *We can now drag two radio buttons onto the form and rename the text of one to Male and the other to Female. *After these have been positioned we can code the methods to populate the dates and tie the two radio buttons together.
The first item on the agenda will be the two radio buttons. *We are going to tie them together so that the two cannot be both checked. *To do this we need to check and see if the opposite radio button is checked. *We will do this by utilizing the CheckedChanged event handler for both radio buttons and this code:
private void rbMale_CheckedChanged(object sender, EventArgs e) { if (rbMale.Checked == true) rbFemale.Checked = false; else rbFemale.Checked = true; } private void rbFemale_CheckedChanged(object sender, EventArgs e) { if (rbFemale.Checked == true) rbMale.Checked = false; else rbMale.Checked = true; }Next we are going to populate the combo boxes we dragged onto the form earlier. *To do this we are going to have to check which one is picked and populate the days for that particular month. *Leap Years are an advanced function that will be implemented in the next tutorial but will be important to the final build. *We are also going to code a for loop to add the years 1900 to 2010 dynamically on the forms startup. *We can do both of these by utilizing main_Load and the cbMonth_SelectedValueChanged event handlers. *The code will look something like this:
private void main_Load(object sender, EventArgs e){ for (int i = 2010; i >= 1900; --i) cbYear.Items.Add(i);}private void cbMonth_SelectedValueChanged(object sender, EventArgs e) { cbDay.Items.Clear(); if (cbMonth.Text == "September" || cbMonth.Text == "April" || cbMonth.Text == "June" || cbMonth.Text == "November") for (int i = 1; i