Database Reference
In-Depth Information
will remove the country or state, and Show Details will show the selection made with a CheckBox and
RadioButton. To do so, you need to write the code functionality behind the click event of all these
buttons one by one.
15. Double-click the Add button and write the following code inside the
btnAdd_Click event, which will read the country and state name entered into
the textboxes and add them to the ListBox and ComboBox.
lstCountry.Items.Add(txtCountry.Text);
txtCountry.Clear();
cboState.Items.Add(txtState.Text);
txtState.Clear();
16. Double-click the Remove Country button, and write the following code inside
the btnRemoveCountry_Click event, which will remove the selected country
from the ListBox named lstCountry:
lstCountry.Items.Remove(lstCountry.SelectedItem);
17. Double-click the Remove State button, and write the following code inside the
btnRemoveState_Click event, which will remove the selected state from the
ComboBox named cboState.
cboState.Items.Remove(cboState.SelectedItem);
18. Double-click the Show Details button, and write the following code inside the
btnShowDetails_Click event, which will show the options selected via a
CheckBox and RadioButton.
if (chkEmail.Checked == true || chkPostalMail.Checked == true &&
rdbMale.Checked == true)
{
19. MessageBox.Show("Hello Mr, you will be contacted by either USPS or email",
"Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
if (chkEmail.Checked == true || chkPostalMail.Checked == true
&& rdbFemale.Checked == true)
{
MessageBox.Show("Hello Mam, you will be contacted by either USPS or email",
"Information", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
}
20. Go to the Build menu and select Build Solution. You should see a message
indicating a successful build.
21. Keep your current project open, because you'll need it immediately for the
next exercise. (Don't worry, we'll explain how this and the next exercise work
afterward.)
 
Search WWH ::




Custom Search