J
JimGreen
I have 2 questions:
1. I have a base class called
class MyBaseObject
{
}
All my classes are derived from MyBaseObject.
I also have a collection dervied from IBindingList and CollectionBase
like so,
class MyCollection : CollectionBase,IBindingList
{
....
}
I also have a class called Customer derived from MyBaseObject
class Customer: MyBaseObject
{
public CustomerId
{
get { return _CustomerId;}
set { _CustomerId = value;}
}
Now I add a few customers to my collection class.
MyCollection myColl = new MyCollection();
myColl.Add ( new Customer(1));
myColl.Add ( new Customer(2));
myColl.Add ( new Customer(3));
At some point in the form, I attach the collection to the datagrid
datagrid1.Datasource = myColl;
Problem:
I see the number of rows in the datagrid to be 3 ( left side sticky
col) but I don't see the columns.
I know the problem. My Customer class is derived from MyBaseObject
class and MyBaseObject doesnot have any public properties.
If I remove MyBaseObject from the picture by not deriving Customer from
MyBaseObject, everything works fine : I see CustomerId column being
displayed on the grid.
You must have guessed my question. How do I take care of the problem.
Thanks for reading the post.
1. I have a base class called
class MyBaseObject
{
}
All my classes are derived from MyBaseObject.
I also have a collection dervied from IBindingList and CollectionBase
like so,
class MyCollection : CollectionBase,IBindingList
{
....
}
I also have a class called Customer derived from MyBaseObject
class Customer: MyBaseObject
{
public CustomerId
{
get { return _CustomerId;}
set { _CustomerId = value;}
}
Now I add a few customers to my collection class.
MyCollection myColl = new MyCollection();
myColl.Add ( new Customer(1));
myColl.Add ( new Customer(2));
myColl.Add ( new Customer(3));
At some point in the form, I attach the collection to the datagrid
datagrid1.Datasource = myColl;
Problem:
I see the number of rows in the datagrid to be 3 ( left side sticky
col) but I don't see the columns.
I know the problem. My Customer class is derived from MyBaseObject
class and MyBaseObject doesnot have any public properties.
If I remove MyBaseObject from the picture by not deriving Customer from
MyBaseObject, everything works fine : I see CustomerId column being
displayed on the grid.
You must have guessed my question. How do I take care of the problem.
Thanks for reading the post.