473,473 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Selecting item in data bound combo box

I have a data bound combo box. The combo box displays several items (status
code descriptions). After the combo box is bound, I want to set the combo box
so that the "Draft" status is displayed by default. Since the data originally
comes from a database I don't know which position in the combo box it will be
and I don't want to hardcode the status_code field (I want to select the
combo box item based upon status_desc).
cb_status.DataSource = ds.Tables["status_code"];
cb_status.DisplayMember = "status_desc";
cb_status.ValueMember = "status_code";
// set combo box to display "Draft" status by default
Thanks in advance
Mar 15 '06 #1
4 2660
vj
so you know only "Draft", which is a Status_Code or Status_Desc?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
I have a data bound combo box. The combo box displays several items (status
code descriptions). After the combo box is bound, I want to set the combo
box
so that the "Draft" status is displayed by default. Since the data
originally
comes from a database I don't know which position in the combo box it will
be
and I don't want to hardcode the status_code field (I want to select the
combo box item based upon status_desc).
cb_status.DataSource = ds.Tables["status_code"];
cb_status.DisplayMember = "status_desc";
cb_status.ValueMember = "status_code";
// set combo box to display "Draft" status by default
Thanks in advance

Mar 15 '06 #2
Yes - I only know Draft and it is a a status_desc

Evan

"vj" wrote:
so you know only "Draft", which is a Status_Code or Status_Desc?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
I have a data bound combo box. The combo box displays several items (status
code descriptions). After the combo box is bound, I want to set the combo
box
so that the "Draft" status is displayed by default. Since the data
originally
comes from a database I don't know which position in the combo box it will
be
and I don't want to hardcode the status_code field (I want to select the
combo box item based upon status_desc).
cb_status.DataSource = ds.Tables["status_code"];
cb_status.DisplayMember = "status_desc";
cb_status.ValueMember = "status_code";
// set combo box to display "Draft" status by default
Thanks in advance


Mar 15 '06 #3
vj
Did u try setting cb_status.Text = "Draft";

Also what is your DropDownStyle?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
Yes - I only know Draft and it is a a status_desc

Evan

"vj" wrote:
so you know only "Draft", which is a Status_Code or Status_Desc?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
>I have a data bound combo box. The combo box displays several items
>(status
> code descriptions). After the combo box is bound, I want to set the
> combo
> box
> so that the "Draft" status is displayed by default. Since the data
> originally
> comes from a database I don't know which position in the combo box it
> will
> be
> and I don't want to hardcode the status_code field (I want to select
> the
> combo box item based upon status_desc).
>
>
> cb_status.DataSource = ds.Tables["status_code"];
> cb_status.DisplayMember = "status_desc";
> cb_status.ValueMember = "status_code";
> // set combo box to display "Draft" status by default
>
>
> Thanks in advance


Mar 15 '06 #4
Setting the text property solved the problem. I didn't try that because I
thought it wouldn't work (I must have been thinking of something else or
another language or maybe my brain just wasn't working)

Evan
"vj" wrote:
Did u try setting cb_status.Text = "Draft";

Also what is your DropDownStyle?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
Yes - I only know Draft and it is a a status_desc

Evan

"vj" wrote:
so you know only "Draft", which is a Status_Code or Status_Desc?

VJ

"Evan" <Ev**@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
>I have a data bound combo box. The combo box displays several items
>(status
> code descriptions). After the combo box is bound, I want to set the
> combo
> box
> so that the "Draft" status is displayed by default. Since the data
> originally
> comes from a database I don't know which position in the combo box it
> will
> be
> and I don't want to hardcode the status_code field (I want to select
> the
> combo box item based upon status_desc).
>
>
> cb_status.DataSource = ds.Tables["status_code"];
> cb_status.DisplayMember = "status_desc";
> cb_status.ValueMember = "status_code";
> // set combo box to display "Draft" status by default
>
>
> Thanks in advance


Mar 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember =...
1
by: Randy Harris | last post by:
I can easily select a row in a listbox with: Me.lstMyListBox = "Some Data" if "Some Data" is in a record in the bound column. Is there any way to select a record based on a column other than the...
9
by: Bob Alston | last post by:
I have a drop down combo box that gives the user to enter an item not in the list by adding it to the list. The list is a table. It works fine on Access2003 but fails on Access2002/XP. ON XP, it...
6
by: Johann Blake | last post by:
I fill a table in a dataset with values that will be used by a combobox for the combobox's items. The combobox is a drop down list that only allows the user to select from the list but not enter...
6
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
2
by: jw01 | last post by:
I have a form in which there is one combo box and three text boxes: Combo Box: -> Item A -> Item B -> Item C TextBox1: TextBox2: ...
10
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...
1
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
4
by: sree078 | last post by:
I've a list of items which I bound to multiple combo boxes. In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.