[dba-VB] Listbox on VB.Net Form - How to Display Data Correctly?

Dan Waters df.waters at comcast.net
Tue May 17 16:00:22 CDT 2011


I'm making my first .net form with existing data and I'm having trouble
getting the listbox to display correctly.  Been looking through all my books
and doing lots of web searches, but no real answer.

 

The form has a TurnbackMainBindingSource which uses a DataSource named
TurnbackMain.  TurnbackMain is an object in a Linq to SQL DataContext (.dbml
file).

 

I have two list boxes, both of which use an items collection entered via
property sheet.  The Severity listbox has choices 1, 2, 3.  The QD listbox
has choices Quality, Delivery.  Both listboxes, have the SelectedItem set to
TurnbackMainBindingSource - Severity and TurnbackMainBindingSource - QD,
respectively.  The comboboxes and textboxes have similar values in the Text
property, but the listbox does not have a Text property in the property
sheet.

 

As I use the Navigation toolbar to move the form through the records, I want
the listboxes to display like Access does, which I assume is the way a
listbox should in .Net as well.

 

What happens:

 

    For the QD listbox, as I scroll through the records, the Quality or
Delivery item is highlighted, if the underlying data is not null.  If the
underlying data is null, then whatever was highlighted for the previous
record remains highlighted.

 

    For the Severity listbox, there is no highlighting at all.

 

    For the comboboxes and textboxes, what's displayed matches the
underlying data.

 

The underlying data for QD is string, the underlying data for Severity is
numeric.

 

Is there a way to make this happen correctly without writing any code in the
form's afterupdate event?  If no, then what code is needed?

 

Thanks!

Dan




More information about the dba-VB mailing list