473,379 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Very Unpredictable ListBox Behaviour

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

Mar 3 '06 #1
2 1229
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

"alanb" <ab**********@gmail.com> schreef in bericht
news:11**********************@v46g2000cwv.googlegr oups.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

Mar 4 '06 #2
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

Mar 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M Wells | last post by:
Hi All, I am developing an Access 2003 project application with the back end in SQL Server 2003. I have a master form that tracks projects, and several subforms on it that track various...
6
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu,...
3
by: Pafo007 | last post by:
Hi. I've built a small window, with some buttons and labels, and one listbox. During design time, I put five lines in the listbox and launch the program: the listbox appears empty! I can select...
2
by: Vikas | last post by:
I am working on an application that has been developed using Visual Basic .net and Visual Studio.net (Framework version 1.0). The application works perfectly on Windows 2000/XP. On windows 98...
2
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I...
3
by: Alec MacLean | last post by:
Hi everyone, I have a ComboBox that when changed, calls a method to change the content of a ListBox. I'm also using the Listbox's SelectedIndexChanged event to change other control values on...
4
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each...
6
by: rahulnag22 | last post by:
Hi, Is it possible to have different items in a listbox in different colors? Or is it just one color for all items in a listbox? Thanks Rahul
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.