system._ComObject databinding [modified]
-
I have a class that interops with a booking tool, the class only returns system._ComObjects I can do late binding cause I know what type is being returned.
public BindingList<NameElement> GetPassengers()
{
BindingList<NameElement> names = new BindingList<NameElement>();
ComClass _comClass = new ComClass();
comClass.RetrieveCurrent();
// comClass.IObj_NameElements contains 2 system._ComObject
foreach (NameElement name in comClass.IObj_NameElements)
// The cast to NameElement is successful
{
names.Add(name);// I fill up a list of 2 NameElement objects
}
return names;
}The problem is that when I try to use this list to bind it to a control by setting it's datasource to this list, the displaymember and valuemember can't be set because I get the error : 'Cannot bind to the new display member. Parameter name: newDisplayMember' Calling properties from the NameElement objects is no problem:
Console.WriteLine(names[0].LastName)
I have no clue why the data binding doesn't work ... :doh: Any help is as appreciated.
modified on Wednesday, January 27, 2010 8:40 AM