By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

Data-bound listbox prevents other controls from handling events!

P: n/a
Greetings!

I am struggling to understand data binding in VB.Net, and it's slow
going.

I have a list box bound to a dataset that is filled from a SQL Server
table. In addition to the list box, I have two buttons on the form.
When I click one, a data adapter's Fill() method gets data into the
table, and the column the list box is bound to obligingly appears in
the list box. The other button merely displays a message box when it
is clicked.

If I click the first button, wait for the list box to fill, and then
click the second button without doing anything in the list box, the
message box appears. I can also click the X in the upper right corner
of the form, and the form will close. But if I click in the list box
to select a different record in the table and then click on the second
button, the button appears to be depressed as usual, but the message
box does not appear! The same thing happens with the X. Its
appearance changes as expected when I click on it, but the form stays
open.

The data objects were all created by dragging them from the Server
Explorer onto the form and configured with their appropriate
designers. The only code I wrote was a single line to call Fill() and
another line to call MessageBox.Show().

Why is the list box being so selfish?
The task I was trying to do when I saw this behavior was to get a
second control to change when I selected a new record in the list box.
I dropped a text box onto the form and bound it to one of the columns
in the same dataset and table the list box was bound to. I wanted to
see the contents of that text box change when a different record was
selected in the list box. It didn't happen. What do I have to do to
get that to happen?

Thanks very much!

Rob
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rob,

I cannot get really behind what you write, however the combobox and the
listbox (both inherit listcontrol) have the nasty behaviour that they fires
events when the datasource is loaded.

To prevent that is the easiest thing to do to use a switch as datasource
loaded on the place where you are sure that is done.

Than use in your selection index change event check that event as start.
If EverythingIsLoadedSwitch then
.........
End if

I hope this helps and otherwise you can show some code to show us what your
problem can be?

Cor
Nov 21 '05 #2

P: n/a
Cor,

I am sorry, but I can't show you code. There isn't any! The whole
project was set up using the IDE and dragging objects from the toolbox
onto the form.

I tried setting the exact same controls bound to the exact same table,
but creating the bindings at run time instead of design time. No
problem!

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.