readononly list add and remove itemsreadononly list add and remove items
Old forum URL: forums.lhotka.net/forums/t/7059.aspx
griff posted on Monday, June 08, 2009
Hi
I have a grid (dev express) and bind to a readonly list.
I then select rows in the grid and want to create a new list (or edit existing) containing only the selected rows which will then be bind to a second grid - can anyone please advise on how I can achieve this?
Thanks
RichardFintanv replied on Tuesday, June 09, 2009
You may wish to consider using an editable list rather than a readonly list. The children would also be derived from the editable base class (rather than the readonly), but may expose read-only properties. This should give you the needed functionality to add and remove items from the list and accomplish the functionality you are after.griff replied on Tuesday, June 09, 2009
Hi
thanks for the reply - okay I will take your advice - I'm very surprised though that this functionality is not available - a standard say two list box scenario with listbox1 providing available list items and listbox2 showing selected items (via 'select' and 'de-select' buttons sandwiched between the two listboxes) - I can't believe this can't be done with read only objects.
RichardBrette.Net replied on Tuesday, June 09, 2009
I have the very same scenario. What I did was add two methods in my ReadOnlyListBase<T> class AddItem(T item) and RemoveItem(T item) in those methods you unlock the list, add/remove the item and then lock the list.
griff replied on Thursday, June 11, 2009
thanks, did the following
Public Overloads Sub AddItem(ByVal info As JobLinesNotInvoicedInfo)
Me.RaiseListChangedEvents = False
IsReadOnly = False
Add(info)
IsReadOnly = True
Me.RaiseListChangedEvents = True
End Sub
Public Overloads Sub RemoveItem(ByVal info As JobLinesNotInvoicedInfo)
Me.RaiseListChangedEvents = False
IsReadOnly = False
Remove(info)
IsReadOnly = True
Me.RaiseListChangedEvents = True
End SubCopyright (c) Marimer LLC