|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Very Unpredictable ListBox Behaviourall 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 Alanb,
Are you sure that this is not happen when you delete a selected item. Than there is a selectedindex change event and that will be triggered. I hope this helps, Cor Show quoteHide quote "alanb" <abilsboro***@gmail.com> schreef in bericht news:1141425967.858678.219340@v46g2000cwv.googlegroups.com... > 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 > Many thanks for the reply Cor,
I've added more protection to the events and yes it does seem to be much more stable - it's even more difficult to reproduce the problem now, BUT it still happens on rare occasions! When I create a new file the program seems to run very well, however the problem seems to happen only after I've stopped the program and run it again (although it still very rarely happens and not immediately after loading the previous data) . I save my data via serialization rather than dumping to a database - I'm beginning to wonder if this is causing a problem. Alan
USB Pen Drive Detection - Retrieving
Dates are Evil! HELP! Class in a module or class in a class? What's going on in this ADO2 code Countdown/pause/resume timer Cannot add MSWord reference Adding New member to TextBox.. using a integer variable with a vb.net datetime literal how linkitem and linkTopic to migrate in vb.net __declspec(dllexport) c++ |
|||||||||||||||||||||||