M
ME
I have an object we'll call it MyObject. MyObject has a property calld
MyBusinessObjects of type List<IMyBusinessObject2>. IMyBusinessObject2 is a
defined interface in my application (See below). I want to bind the
MyBusinessObjects property to a ComboBox as follows:
ComboBox cbData = new ComboBox();
BindingSource bsSource = new BindingSource();
bsSource.DataSource = MyObject.MyBusinessObjects;
cbData.DisplayMemeber = "Text";
cbData.ValueMember = "Index";
cbData.DataSource = bsSource;
When I run the code I get just the type name (like
'namespace.MyBusinessObjects') of the object in the drop down or I will get
an error that says that the field "Text" does not exist. However if I
change the object in the collection to use the base interface
(IMyBusinessObject) it works fine. How can I bind a control to a business
object that uses an extended interface?
Thanks,
Matt
---------------------------------------------------
public interface IMyBusinessObject2 : IMyBusinessObject
{
}
public interface IMyBusinessObject
{
int Index
{
get;
set;
}
string Text
{
get;
set;
}
}
MyBusinessObjects of type List<IMyBusinessObject2>. IMyBusinessObject2 is a
defined interface in my application (See below). I want to bind the
MyBusinessObjects property to a ComboBox as follows:
ComboBox cbData = new ComboBox();
BindingSource bsSource = new BindingSource();
bsSource.DataSource = MyObject.MyBusinessObjects;
cbData.DisplayMemeber = "Text";
cbData.ValueMember = "Index";
cbData.DataSource = bsSource;
When I run the code I get just the type name (like
'namespace.MyBusinessObjects') of the object in the drop down or I will get
an error that says that the field "Text" does not exist. However if I
change the object in the collection to use the base interface
(IMyBusinessObject) it works fine. How can I bind a control to a business
object that uses an extended interface?
Thanks,
Matt
---------------------------------------------------
public interface IMyBusinessObject2 : IMyBusinessObject
{
}
public interface IMyBusinessObject
{
int Index
{
get;
set;
}
string Text
{
get;
set;
}
}