Hi
using a NVL as the datasource for a listbox and want to remove an item from the list.
I have added a sub.....
Public
Overloads Sub Remove(ByVal clientID As Int32)For Each res As NameValuePair In Me
If res.Key = clientID Then
Me.remove(res) Exit For End If Next End Sub
This throws the following error...
"Remove is an invalid operation"Can anyone shed light on this, thanks
Richard
The NVL base class extends ReadOnlyBindingList - the list is always ReadOnly.
You need to make it editable while you do your change. The following code is an example:
// Stop raising list events while changing the list// Make the list not ReadOnly (so it can be changed)
IsReadOnly = false;
// Do some changes here....
<snip>;
// Make the list ReadOnly again
IsReadOnly = true;
// Start raising list events again
RaiseListChangedEvents = true;
Thanks that sorted it.
Richard
Hi
further to this....removing the item from the list works fine and I can now add into the list in a similar fashion. However the newly added item is added to the bottom of the lstBox/NVL - how do you apply sorting to the NVL?
Richard
No, but how would I know what the value of 'index' was?
I'm looking into using a sorted list to handle this
Richard
You'd have to work out what the index was for yourself.
Don't forget that the main purpose behind the NVL is to populate drop-down list style controls from data in a DB table. Usually all the sorting is done when you get the data from the DB.
It sounds like you've got a slightly different requirement here. So that means you need to write some slightly different code to handle your specific case.
The best solution will always be to sort the data before you start building the NVL though.
HTH.
Copyright (c) Marimer LLC