Nel

Nel

  • NA
  • 716
  • 1.1m

Problem with displaying the value of the selected row in datagridview in the combobox control

Feb 23 2012 7:57 AM
Hi ,

I  have a combobox and when clicking on a datagridview row I  retrieve the values of  the row in the combobox, datatimepicker and other controls on the form.... But the  combobox.selecteditem  doesn't return the correct value. I wrote messagebox.show(Convert.ToString(comboBox1.selectedItem)) and I saw that it returns System.Data.DataGridView .

I have this line:
comboBox1.SelectedItem =Convert.ToInt32(dataGridView2.SelectedRows[0].Cells[0].Value);
but the combobox's  value is not changing when clicking on different rows  in  the datagridview.
Can you please help me?

Thanks in advance

Answers (4)