Dear Rod,
It seems that there is a problem with âdata bound ComboBoxâ with âVisual Basic 2005â
I tried the topic in Chapter 11 Database Controls & Objects, Complex Data Binding, p 356.
I tried thisâ¦
(I used SQL 2005 Express for database.)
Create a new Windows Application.
Add a new database named âComputerUsers.mdfâ
In the DataSource Configuration Wizard, click cancel (since thereâs no table yet)
In Server Explorer, create two tables Users and UserTypes with the following definitions:
Users table
FirstName varchar(50) notnull
LastName varchar(50) notnull
UserType int notnull
UserTypes table
UserTypeId int notnull primaryKey
UserTypeName varchar(50) notnull
In the Diagram, add the two tables, then drag the UserType field of Users table to UserTypeId field of UserTypes table.
This will create a relation FK_Users_UserTypes with
Primary key UserTypes-UserTypeId
Foreign key User-UserType
Save the diagram.
Fill the UserTypes table (using Server Explorer):
UserTypeID UserTypeName
1 Programmer
2 Project Manager
3 Department Manager
4 Program Manager
5 Lab Director
In the Data Source, click âAdd New Data Sourceâ, select ComputerUsers.mdf and check the âtables check boxâ to include the two tables in the new ComputerUsersDataSet.
The âData Sourcesâ now displays ComputerUsersDataSet with the two tables Users & UserTypes.
Expand (click the +) Users table to display the fields.
Click on the UserType field, click again on the dropdown and select âComboBoxâ
In the Users table dropdown, select Details.
Then drag the Users table onto âForm1.
vb [Design]â.
This created the following:
1. two textboxes for FirstName and LastName
2. a ComboBox for UserType field
3. the corresponding labels
4. ComputerUsersDataSet, UsersBindingSource, UsersTableAdapter and UsersBindingNavigator controls
Update some properties of the UserTypeComboBox:
1. DataSource = +Other Data Source, +Project Data Source, +ComputerUsersDataSet, and finally select UserTypes.
This created UserTypesBindingSource and UserTypesTableAdapter
2. DisplayMember = UserTypeName
3. ValueMember = UserTypeId
4. SelectedValue = UsersBindingSource-UserType
When I run the application, select + (add new item), I typed some names for First & Last Name. After chosing one item in the UserTypeComboBox say Programmer, the app just sticked with UserTypeComboBox. Other fields cannot be selected, or clicking the save icon do nothing.
I have to use STOP in VS/
VB IDE.
I tried to change ComboBox.DropDownStyle to Simple, DropDown, and DropDownList but still the same problem.
Any ideas??? Did I missed something???
Larry Sevilla
A novice VB2005 user.