- Open the ExoADO1 application
- Click the text box on the right side of Gender and press Delete
- Add a new combo box where the GenderID text box was:
 |
| Control |
Name |
Text |
Additional Properties |
| ComboBox |
cboGender |
|
DropDownStyle: DropDownList |
|
- To create a data source for the combo box, from the Data section of
the Toolbox, click SqlDataAdapter and click the form
- Click Next
- In the combo box, select Server.People.dbo and click Next
- Accept the default Use SQL Statements radio button and click Next
- Click Query Builder...
- From the Tables property page of the Add Table dialog box, click
Genders. Click Add and click Close
- In the upper section of the Query Builder window, click the GenderID and
the Gender check boxes
- Click OK
- Click Next and click Finish
- To create a data set for the genders, right-click sqlDataAdapter2
and click Generate Dataset...
- Accept the Existing radio button and accept the Genders check box
- Click OK
- On the form, click the combo box
- In the Properties window, set the properties as follows:
DataSource: dsPersons1.Genders
DisplayMember: Gender
ValueMember: GenderID
DataBindings -> SelectedValue: dsPersons1 - Persons.GenderID
- Double-click an empty area of the form and change the Load event as
follows:
private void Form1_Load(object sender, System.EventArgs e)
{
sqlDataAdapter2.Fill(dsPersons1, "Genders");
sqlDataAdapter1.Fill(dsPersons1, "Persons");
}
|
- Press Ctrl + F5 to test the application
|