Nathan,
You can not set the expression for a binding to be a method, which is
what objB is. You have to expose it as a property.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Nathan" <Na****@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hi,
I have a datagridview bound to a List of objects (ObjectA). Each ObjectA
contains an ObjectB property.
Class ObjectA
{
public ObjectB objB {}
}
The datagridview has a combobox column that is bound to each ObjectA's
ObjectB, like this:
List<ObjectA> ObjectAList = new List<ObjectA>();
...
dgv.DataSource = ObjectAList;
dgv.Columns[1].DataPropertyName = "objB";
When the datagridview loads, I get an error in the form of a message box
for
each row that loads:
The following exception occurred in the DataGridView:
System.FormatException: DataGridViewComboBoxCell value is not valid.
The comboboxes all load with the right values, but this error appears as
they load and whenever the datagridview is clicked.
Does anyone know what would cause this behavior?