Confused about presenting a sorted child list

Confused about presenting a sorted child list

Old forum URL: forums.lhotka.net/forums/t/6897.aspx


lukky posted on Monday, May 04, 2009

Hi all,

I'm working on a Windows Forms application with the EditableRoot => EditableChildList => EditableChild pattern. On the Form, I use the 2 BindingSources pattern where BS1.DataSource = Root and BS2.DataSource = Root.ChildList

I'd like to present the ChildList as a sorted list based on a property of Child, and at the same time I'd like to let UI move the Child objects Up/Down (using arrow buttons) so that the user can sort a DataGridView manually.

I've been trying many different scenarios, but none of them work properly. I just can't figure out where to do the sorting.

Any suggestions welcome.

Thanks

Tom_W replied on Tuesday, May 05, 2009

Hey Luc

I'm guessing that just sorting the list when you retrieve it from the database isn't working for you for some reason?

With regards to the moving items up and down I normally just add a 'DisplaySortOrder' type property to the object and persist this to the database too, then let the arrow controls adjust that value and sort on it. (e.g if you move the topmost item down one it increments the DisplaySortOrder property by one for the top item and decrements the display sort order for the second item in the list)

Are the issues you are having with the BindingSource.Sort and DataGridView sort methods?  I'm really rusty on all of those as we use the Infragistics WinGrid for the sorting.

Cheers

Tom

RockfordLhotka replied on Tuesday, May 05, 2009

Have you looked at the Csla.SortedBindingList class? It wraps any IList and makes that list sortable.

 

Copyright (c) Marimer LLC