By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,319 Members | 2,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

Binding data to a Combo Box

P: n/a
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend.
I have created a combo box which is to populate with 'STATUS_DESC' from the STATUS table.
This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up the STATUS table with POHEADER.STATUS_ID.
How come when I fill the dataset, the combo box gets the STATUS_ID instead?

I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to find that anywhere in the properties dialog.
Please help! How do i get it to lookup the description once it's retrieved the STATUS_ID from the Dataset?
THANKS!!
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What do you mean when you say the Combo box 'Gets' the STATUS_ID, do you
mean that is what is displayed ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"SoftWhiteDelgiht" <So**************@discussions.microsoft.com> wrote in
message news:79**********************************@microsof t.com...
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with 'STATUS_DESC' from the STATUS table. This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up the STATUS table with POHEADER.STATUS_ID. How come when I fill the dataset, the combo box gets the STATUS_ID instead?
I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to find that anywhere in the properties dialog. Please help! How do i get it to lookup the description once it's retrieved the STATUS_ID from the Dataset?

THANKS!!

Nov 20 '05 #2

P: n/a
Hi Terry,
Yes, it displays the id instead of the description.
ie. When the screen first displays it populates the combo box with all the statuses. 'Approved', 'Closed' etc.
When I enter a Purchase Order number and fill the dataset, the Combo Box displays the number 5 and it is no longer populated with the statuses.
Here is the code:

Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("Tag", Me.DsPurchaseOrder1, "POHEADER.PO_PONO"))
Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsPurchaseOrder1, "POHEADER.PO_STATUS"))
Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.DsPurchaseOrder1, "POHEADER.PO_STATUS"))
Me.ComboBox1.DataSource = Me.DsPurchaseOrder1.STATUS
Me.ComboBox1.DisplayMember = "STATUS_DESC"
Me.ComboBox1.Location = New System.Drawing.Point(464, 121)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(120, 21)
Me.ComboBox1.TabIndex = 63
Me.ComboBox1.Tag = ""
Me.ComboBox1.ValueMember = "STATUS_ID"

Thanks for your help.
Regards,
Marnie.

"One Handed Man ( OHM - Terry Burns )" wrote:
What do you mean when you say the Combo box 'Gets' the STATUS_ID, do you
mean that is what is displayed ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"SoftWhiteDelgiht" <So**************@discussions.microsoft.com> wrote in
message news:79**********************************@microsof t.com...
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple

master/detail form with a SqlServer backend.
I have created a combo box which is to populate with 'STATUS_DESC' from

the STATUS table.
This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up

the STATUS table with POHEADER.STATUS_ID.
How come when I fill the dataset, the combo box gets the STATUS_ID

instead?

I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to

find that anywhere in the properties dialog.
Please help! How do i get it to lookup the description once it's retrieved

the STATUS_ID from the Dataset?


THANKS!!


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.