PC Review


Reply
Thread Tools Rate Thread

Data-bound listbox prevents other controls from handling events!

 
 
Rob Richardson
Guest
Posts: n/a
 
      28th Aug 2004
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
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      29th Aug 2004
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


 
Reply With Quote
 
Rob Richardson
Guest
Posts: n/a
 
      29th Aug 2004
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bound listbox freezes form events peteg Microsoft Dot NET Framework Forms 0 21st Dec 2007 02:18 PM
User Controls: Handling Events Quina Microsoft Dot NET 4 19th Jul 2007 07:18 PM
preventing controls from handling key events =?Utf-8?B?TWljaGFsIFJpemVr?= Microsoft Dot NET Compact Framework 3 30th Jan 2005 04:26 PM
Bound Controls Update Events =?Utf-8?B?TGVuc3Rlcg==?= Microsoft VB .NET 4 18th Aug 2004 03:46 PM
Handling Events in Nested Controls DotNetGuru Microsoft ASP .NET 1 26th Jun 2003 10:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:16 AM.