469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Using BindingNavigator and ComboBox of data bound items

bds
I'm new to .net 2.0 and I'm trying to figure out the best way to create a
form that has a couple of controls and one of the controls is a combo box
with a data bound list of items from another table.

To understand the problem more, consider using the AdventureWorks2000
database. I want a simple form that shows FirstName, LastName, and Shift.
Instead of the ShiftID, I want the shift name from the Shift table to be
displayed.

Here's what I've tried:
1. Create dataset with Employee table and Shift Table.
2. Drag employee FirstName and LastName on the form
3. A BindingNavigator and BindingSource were created when FirstName was
dragged onto the form.
4. Change ShiftID to a comboBox and drag it onto the form
5. Configure the combobox to bind to the ShiftBindingSource
6. Select ShiftId as the Value Memeber.
7. Select Name as the Display Member
I have two problems:
1. Once the data item list is displayed in the combobox, the Display Member
(Shift.Name) is not the right display member for the display value
(employee.ShiftId). Do I have to synchronize the two BindingSources? Do I
have to use only one BindingSource and join Employee and Shift in one query?
Something else?

2. How do I make ShiftID get inserted or updated in the employee table from
a selection in the comboBox?

--
-bds
Aug 17 '05 #1
2 9160
Hi,

"bds" <bd*@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
I'm new to .net 2.0 and I'm trying to figure out the best way to create a
form that has a couple of controls and one of the controls is a combo box
with a data bound list of items from another table.

To understand the problem more, consider using the AdventureWorks2000
database. I want a simple form that shows FirstName, LastName, and Shift.
Instead of the ShiftID, I want the shift name from the Shift table to be
displayed.

Here's what I've tried:
1. Create dataset with Employee table and Shift Table.
2. Drag employee FirstName and LastName on the form
3. A BindingNavigator and BindingSource were created when FirstName was
dragged onto the form.
4. Click on the arrow next to the Shift table ( not ShiftID )
(4.1 If you don't see an option for combobox then click customize and check
combobox)
4.2 Change Shift table to combobox

5. Drag Shift Table onto form, you should see a combobox on the form

6. Open combobox properties
6.1 Check if DataSource/ DisplayMember and ValueMember are correct
6.2 Expand (DataBindings)
(6.3 If you see a binding for Text then click on the arrow and set the
binding to None)
6.4 Click on the arrow next to SelectedValue and bind to
EmployeeBindingSource - ShiftID
That should make the combobox work in both directions (from and to
Employee).

HTH,
Greetings


I have two problems:
1. Once the data item list is displayed in the combobox, the Display
Member
(Shift.Name) is not the right display member for the display value
(employee.ShiftId). Do I have to synchronize the two BindingSources? Do
I
have to use only one BindingSource and join Employee and Shift in one
query?
Something else?

2. How do I make ShiftID get inserted or updated in the employee table
from
a selection in the comboBox?

--
-bds

Aug 17 '05 #2
bds
That's it. Thanks.

I guess the key thing I was missing was dragging the whole table out (the
Shift table in my case).

--
-bds
"Bart Mermuys" wrote:
Hi,

"bds" <bd*@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
I'm new to .net 2.0 and I'm trying to figure out the best way to create a
form that has a couple of controls and one of the controls is a combo box
with a data bound list of items from another table.

To understand the problem more, consider using the AdventureWorks2000
database. I want a simple form that shows FirstName, LastName, and Shift.
Instead of the ShiftID, I want the shift name from the Shift table to be
displayed.

Here's what I've tried:
1. Create dataset with Employee table and Shift Table.
2. Drag employee FirstName and LastName on the form
3. A BindingNavigator and BindingSource were created when FirstName was
dragged onto the form.


4. Click on the arrow next to the Shift table ( not ShiftID )
(4.1 If you don't see an option for combobox then click customize and check
combobox)
4.2 Change Shift table to combobox

5. Drag Shift Table onto form, you should see a combobox on the form

6. Open combobox properties
6.1 Check if DataSource/ DisplayMember and ValueMember are correct
6.2 Expand (DataBindings)
(6.3 If you see a binding for Text then click on the arrow and set the
binding to None)
6.4 Click on the arrow next to SelectedValue and bind to
EmployeeBindingSource - ShiftID
That should make the combobox work in both directions (from and to
Employee).

HTH,
Greetings


I have two problems:
1. Once the data item list is displayed in the combobox, the Display
Member
(Shift.Name) is not the right display member for the display value
(employee.ShiftId). Do I have to synchronize the two BindingSources? Do
I
have to use only one BindingSource and join Employee and Shift in one
query?
Something else?

2. How do I make ShiftID get inserted or updated in the employee table
from
a selection in the comboBox?

--
-bds


Aug 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael Schindler | last post: by
2 posts views Thread by John Tyce | last post: by
1 post views Thread by Norm Katz | last post: by
2 posts views Thread by GS | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.