I'm developing a windows application in VB.NET 2005. I have a form with an unbound DataGridView control. One of the columns in this DataGridView is a databound ComboBox column. It retrieves records from a lookup in table in a SQL Server database. The table has a ID (numeric) field that corresponds to the ValueMember property of the ComboBox. There is also a Description (text) field that corresponds to the DisplayMember property of the ComboBox. So far, so good.
What I am trying to do now is to programatically set the SelectedValue of this ComboBox. Since this ComboBox is embedded within the DataGridView control, I am not able to set the selectedValue as I would with a ComboBox that is not embedded. I want to be able to set what is seen in the ComboBox by using the ID field, and not the Description field.
For now, I'm just using a test button on the windows form to try and work out this code. I only have one line of code in there now.
Here is the error that I am getting...
The following exception occurred in the DataGridView:
System.FormatException: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event.
Thanks in advance for your help...
What I am trying to do now is to programatically set the SelectedValue of this ComboBox. Since this ComboBox is embedded within the DataGridView control, I am not able to set the selectedValue as I would with a ComboBox that is not embedded. I want to be able to set what is seen in the ComboBox by using the ID field, and not the Description field.
For now, I'm just using a test button on the windows form to try and work out this code. I only have one line of code in there now.
Code:
Me.datRecords.Rows(0).Cells(3).Value = 9
The following exception occurred in the DataGridView:
System.FormatException: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event.
Thanks in advance for your help...