LarrySevilla
New member
- Joined
- Oct 15, 2006
- Messages
- 4
- Programming Experience
- Beginner
(I'm not sure if this is the right forum)
It seems that there is a problem with “data bound ComboBox” with “Visual Basic 2005”
Please try 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.
Select “Form1.vb [Design]” and select back “Data Sources”.
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 selected 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
VB2005 Novice user
App Source:
Visual Basic 2005 Programmer’s Reference by Rod Stephens
Chapter 11 Database Controls & Objects,
Complex Data Binding, p 356.
It seems that there is a problem with “data bound ComboBox” with “Visual Basic 2005”
Please try 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.
Select “Form1.vb [Design]” and select back “Data Sources”.
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 selected 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
VB2005 Novice user
App Source:
Visual Basic 2005 Programmer’s Reference by Rod Stephens
Chapter 11 Database Controls & Objects,
Complex Data Binding, p 356.