Link to home
Start Free TrialLog in
Avatar of paulofonsecajr
paulofonsecajr

asked on

How to select a combobox item by value?

I have a combobox with datasource, display member and value member configured (retrieving by data table) and I want to update a data table row in a form. The combobox must be populated and the actual value need to be selected. I try to do it with this.combobox1.SelectValue = DataTableValue but the item not changed. Oh! I forgot to say a important question: I don´t want to use SelectedIndex. I want to select the item by value. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Death259
Death259
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of paulofonsecajr
paulofonsecajr

ASKER

Yes, I try:

this.comboTabelaPorModeloDocumento.SelectedValue = Convert.ToInt32(dRow.Cells["tabelaDicionarioDados"].Value);

and

this.comboTabelaPorModeloDocumento.SelectedValue = dRow.Cells["tabelaDicionarioDados"].Value.ToString();

But it not works.
Sorry, the event was wrong, I was setting up the value before Form_Load and the combo fill.

Death259. The solution is ok.
Well, if this solved your problem please be sure to mark it as the answer.