We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

collection based on abstract class in DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

11215 Feb 27,2004 02:51 AM Feb 28,2004 03:37 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 27, 2004 02:51 AM

I''ve created base class with property Text, then I created collection based on this class. Collection is used in DataBoundGrid. There are some inherited classes from base class that can be added to collection. Everything is working fine if I add elements to collection from zero. But If I use already filled collection with different inherited types there are problems of displaying this collection in DBG. What can I do?

Administrator [Syncfusion]
Replied On February 27, 2004 04:04 AM

Are you saying you can add a series of base objects to your collection, and then set the collection as the DataSource of a GridDataBoundGrid, then it works? But if you add a series of derived objects to your collection, and then set the collection as the datasource, it does not work? Can you provide a sample project showing the problem?

Administrator [Syncfusion]
Replied On February 27, 2004 05:51 AM


Administrator [Syncfusion]
Replied On February 27, 2004 09:26 AM

Thank you for the sample. The grid uses teh first item in teh list to set up properties, and for some reason this is failing when you add your inherited objects. We will have to look into this to see if this si something we can fix. Until we get it fixed, you could just temporarily add a base class object first, and then remove it after you set the datasource. clsBase loB1=new clsBase(); clsInherited1 loI1=new clsInherited1(); clsInherited2 loI2=new clsInherited2(); mCollection=new clsBaseCollection(); mCollection.Add(loB1); mCollection.Add(loI1); mCollection.Add(loI2); dtg.BeginUpdate(); dtg.DataSource=mCollection; mCollection.Remove(loB1); dtg.EndUpdate(); dtg.Refresh();

Administrator [Syncfusion]
Replied On February 27, 2004 10:55 AM

I used the same approach thank you

Administrator [Syncfusion]
Replied On February 28, 2004 03:37 AM

To get this to work without adding the fake entry at the start, you can implement ITypedList in your collectionbase. This requires deriving PropertyDescriptor to implement proper GetValue and SetValue methods for your derived property descriptor. Here is your sample back modified to do this. forumcollection_4383.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;