Selecting item in data bound combo box

G

Guest

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
 
G

Guest

Yes - I only know Draft and it is a a status_desc

Evan

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

VJ

Evan said:
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
 
V

vj

Did u try setting cb_status.Text = "Draft";

Also what is your DropDownStyle?

VJ

Evan said:
Yes - I only know Draft and it is a a status_desc

Evan

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

VJ

Evan said:
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
 
G

Guest

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 said:
Did u try setting cb_status.Text = "Draft";

Also what is your DropDownStyle?

VJ

Evan said:
Yes - I only know Draft and it is a a status_desc

Evan

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

VJ

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top