4
Reply

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

Ask a question
Nel

Nel

12y
3.1k
1
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)