Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > BOOK: Visual Basic 2005 Programmer's Reference
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2006, 08:01 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with "data bound ComboBox" with "VB 2005"

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.


 
Old October 17th, 2006, 07:36 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

That's strange. I have no ideas what's going on. Can you zip the project up and email it to me at RodStephens@vb-helper.com?

Rod

Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old October 19th, 2006, 06:07 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Rod,

Unbinding the .Text property solved the problem.
It was automatically bound when I dragged the combobox from DataSource into the form.

Thanks for your concern...

Larry Sevilla
VB2005 Novice User


 
Old October 19th, 2006, 07:50 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Strange that it would cause that behavior.

Rod

Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem VB.NET 2005 - update data in Ms Access Netuser Pro Visual Basic 2005 0 August 1st, 2008 01:34 PM
Item Data Bound Problem rstelma ASP.NET 1.0 and 1.1 Professional 3 January 25th, 2006 05:39 PM
Bound ComboBox Database Query dougontour VB.NET 2002/2003 Basics 5 April 20th, 2005 02:11 AM
Blank row in Data Bound ComboBox joblot VB How-To 1 May 5th, 2004 01:33 PM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.