One more try

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.
 
M

Morten Wennevik

Hi Jim,

Using the sample code in the msdn library for IBindingList interface, and tweaking it to have Customer inherit from BaseClass I can successfully display all data and columns in the DataGrid.

Try cut/paste the sample code or show us more of your code.
 
M

Morten Wennevik

Hi Jim,

I'm afraid it does not appear to be included in the online msdn library, but it is included in the msdn library for visual studio.net and should also be in the .net framework SDK documentation.

The help link for the feb 2003 library for vs.net is

Or you can just search for 'IBindingList' and go to the overview


ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemcomponentmodelibindinglistclasstopic.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top