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
close icon

Setting DataSource to an ArrayList

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

2 Replies

AD Administrator Syncfusion Team June 20, 2005 04:44 PM UTC

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.


JJ Jonathan Jones June 20, 2005 08:39 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon