473,657 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding data to a Combo Box

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: DsPurchaseOrder 1.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
2 2156
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

"SoftWhiteDelgi ht" <So************ **@discussions. microsoft.com> wrote in
message news:79******** *************** ***********@mic rosoft.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: DsPurchaseOrder 1.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
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.Da taBindings.Add( New System.Windows. Forms.Binding(" Tag", Me.DsPurchaseOr der1, "POHEADER.PO_PO NO"))
Me.ComboBox1.Da taBindings.Add( New System.Windows. Forms.Binding(" Text", Me.DsPurchaseOr der1, "POHEADER.PO_ST ATUS"))
Me.ComboBox1.Da taBindings.Add( New System.Windows. Forms.Binding(" SelectedValue", Me.DsPurchaseOr der1, "POHEADER.PO_ST ATUS"))
Me.ComboBox1.Da taSource = Me.DsPurchaseOr der1.STATUS
Me.ComboBox1.Di splayMember = "STATUS_DES C"
Me.ComboBox1.Lo cation = New System.Drawing. Point(464, 121)
Me.ComboBox1.Na me = "ComboBox1"
Me.ComboBox1.Si ze = New System.Drawing. Size(120, 21)
Me.ComboBox1.Ta bIndex = 63
Me.ComboBox1.Ta g = ""
Me.ComboBox1.Va lueMember = "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

"SoftWhiteDelgi ht" <So************ **@discussions. microsoft.com> wrote in
message news:79******** *************** ***********@mic rosoft.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: DsPurchaseOrder 1.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1129
by: Premkumar-Prem_kumar2003 | last post by:
Database details:- Four Categories r there. Every Category includes some Description. DATA BINDING FOR SELECTED INDEX CHANGED EVENT:- Req:- 1. Combobox 2. ListBox (or) Textbox (with multiline Property) BINDING:- Combo box will displays Categories
6
1621
by: Brian Henry | last post by:
Here's an example of the code.. I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change (based on a relation) Private ds_formData As New DataSet ' ' Fill Line Of Business ' cmd_selectCommand.CommandText = "BENESP_GetLinesOfBusiness" da_formData.FillSchema(ds_formData, SchemaType.Source, "LinesOfBusiness")
0
1518
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. There are cases where properties of one object is dependant on a property of another object. For a common example, when you bind an ArrayList to a ComboBox using the combo's DataSource property, the combo box fills up with items from the array list....
0
4794
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having manually inserted a row in the table bound to the Combo box. The InsertAt Method of adding a row just does not work. Hope this helps anyone with this problem. john
0
1558
by: oracle | last post by:
Greetings, I have a combo box that I binded to a data set using text and tags. I want it to display the DRT.Name property and have a DRT.UnitId as a value. this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.drtDataSet1, "DRT.UnitId")); this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.drtDataSet1, "DRT.Name"));
1
9826
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt; Field_LV.DataContext = dt; Field_LV.SetBinding(ListView.ItemsSourceProperty, Bind);
3
2437
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When the users selects an item from the combo box I'd like the 4 text boxes to get populated with the corresponding item information from the same dataset table row that the combo box is pulling it's info from. Is there an easy way of doing this besides...
10
5835
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, Problem: How can I databind (or put) a SqlServer query's row return of 115,000 items into a ComboBox quickly? Not much longer than a matter of seconds, that is... Scenario: I am rebuilding my company's Access 97 VBA database app. It pulls 115,000 items (of account names) from SqlServer and the data is bound to a single Access 97 ComboBox control. My C# version needs to work exactly like this one. Our executive employees want...
0
1945
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable, which I then assign to the datasource. Some of my combo box datasources depend on values in other fields to limit the options. For example, I have a sales rep list that is limited by the customer selected in the customers combo box. And...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.