A
alanb
This is driving me NUTS. I have a listbox bound to a datasource and it
all works fine until I start deleting items from the class collection.
The frustrating thing is that there is no pattern to the error and I
can't recreate the problem with any certainty. I refresh the listbox
after deleting a class item with the following code:
With lstBanks
.DataSource = Nothing
.DisplayMember = "Title"
.ValueMember = "BankID"
.DataSource = Banks
End With
Generally everything works fine - after a class item is deleted the
listbox displays the correct items using the refresh code above.
HOWEVER every now and again the listbox starts to fill itself with the
class name, i.e. repeated lines of 'MyProgram.Bank' (the number of
lines is always equivalent to the correct number of items that should
be displayed in the listbox). Then the program will crash when a
listbox item is clicked. It seems obvious to me that the DisplayMember
and ValueMember are not being properly set (or ignored) for some reason
(I have checked these values after the problem appears and they seem to
be set fine).
I have tried just about every combination of lines including refresh,
different order of lines etc. etc..
Any help would be very much appreciated.
Alan
all works fine until I start deleting items from the class collection.
The frustrating thing is that there is no pattern to the error and I
can't recreate the problem with any certainty. I refresh the listbox
after deleting a class item with the following code:
With lstBanks
.DataSource = Nothing
.DisplayMember = "Title"
.ValueMember = "BankID"
.DataSource = Banks
End With
Generally everything works fine - after a class item is deleted the
listbox displays the correct items using the refresh code above.
HOWEVER every now and again the listbox starts to fill itself with the
class name, i.e. repeated lines of 'MyProgram.Bank' (the number of
lines is always equivalent to the correct number of items that should
be displayed in the listbox). Then the program will crash when a
listbox item is clicked. It seems obvious to me that the DisplayMember
and ValueMember are not being properly set (or ignored) for some reason
(I have checked these values after the problem appears and they seem to
be set fine).
I have tried just about every combination of lines including refresh,
different order of lines etc. etc..
Any help would be very much appreciated.
Alan