المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : system._ComObject databinding [modified]



C# Programming
01-28-2010, 01:50 PM
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 GetPassengers()
{
BindingList names = new BindingList();
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 ... http://www.barakasoft.com/script/Forums/Images/smiley_doh.gif

Any help is as appreciated.

modified on Wednesday, January 27, 2010 8:40 AM