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.

Setting DataSource to an ArrayList

Thread ID:





30556 Jun 20,2005 11:21 AM Jun 20,2005 04:39 PM Windows Forms 2
Tags: GridControl
Jonathan Jones
Asked On June 20, 2005 11:21 AM

Hi, I seem to be having a problem setting the DataSource of a GridGroupingControl to an ArrayList. I chose this control because I need the ability to easily sort columns. The ArrayList is always initially empty. Other controls (not part of the grid) add to and remove from the ArrayList (so I assume I don''t need IBindingList support). If I set the DataSource to the empty ArrayList, the contents of the ArrayList are never correct afterwards. It only shows the last column I have defined (instead of all 3). That one column is always empty in every cell (even though every cell should have data). If I fudge it to set the DataSource of the grid after the ArrayList has items in it, it works a little better. All columns are present, and the cells seem to have the correct data. However, I still can never see when new items are added to the ArrayList without clicking on the column headers to force the columns to sort again. I don''t know if this is relevant, but the ArrayList is written in C++, and the GUI code is written in C#. The ArrayList code needs to be in C++, because it is an interface that we expose to our customers, and we can''t assume our customers have knowledge of C#. Any help is appreciated, as I am very stuck. Thanks, - Jonathan

Administrator [Syncfusion]
Replied On June 20, 2005 12:44 PM

I think you can get things to work if you have your arraylist implement ITypedList. Here is a little sample that starts with an empty list, and adds 2 items at a time in button click. http://www.syncfusion.com/Support/user/uploads/GGC_ArrayList_63f8e2e2.zip Whovever changes your arraylist will have to tell teh grid thatthe dat is dirty. Or, you can have a derived arraylist raise an event anytime a member is changed/added/deleted (essentially the IBindingList.ListChanged event). The you can have teh grid listen for your custom event, and have it set itself dirty.

Jonathan Jones
Replied On June 20, 2005 04:39 PM

Hi Clay, Thank you so much! This has solved my problem. In retrospect, this makes sense, but I am fairly new to .NET and very new to Syncfusion, so I simply didn''t know how to proceed. Also, I am using the ArrayListExt to store the data, and having the CollectionChangeEventHandler call grid.Reinitialize() to update the GridGroupingControl. Is this correct? Thanks, - Jon


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.