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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

collection based on abstract class in DataBoundGrid

Thread ID:





11215 Feb 27,2004 07:51 AM UTC Feb 28,2004 08:37 AM UTC WinForms 5
Tags: GridControl
Administrator [Syncfusion]
Asked On February 27, 2004 07:51 AM UTC

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 09:04 AM UTC

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 10:51 AM UTC

Administrator [Syncfusion]
Replied On February 27, 2004 02:26 PM UTC

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 03:55 PM UTC

I used the same approach thank you

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

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon