Second post: Can someone help

  • Thread starter Thread starter consumer62000
  • Start date Start date
C

consumer62000

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.
 
I tried doing this a while back myself, and you need a lot more then just
the IBindingList interface. I would recommend a book:

Expert C# Business Objects
Rocky Lhotka
ISBN: 1-59059-344-8

He spoke at our local user group last year and it was great. This book
should have everything in it you need. He even has created his own
framework that might help you get to where you are going faster.

Hope this helps.

Eric Renken
 
Back
Top