[dba-VB] OT: .NET - Data grid syncs to combo

John W. Colby jcolby at colbyconsulting.com
Tue Feb 25 19:31:41 CST 2003


I have moved my billing database BE to sql server, hooked up my existing
Access FE and continue to use that as I play with the data in .Net.

In the meantime, in VB.Net I created a bound form last night (or I think
it's bound anyway, not positive).  It was using an OLEConnection, which
tonight I switched to an SQL connection.  It's supposed to be faster.  The
form simply displays the state table (all fields) in a data grid.  You
really can't get much simpler than that, though I suppose for something like
a state table it would suffice.

I decided to try and figure out how to use a combo box to select a record in
the data grid.  Dragged and dropped a combo to the form, hooked the
datasource property to the same data source I was using for the form / data
grid.  Set the display member (the field displayed) to ST_Abrev (the 2 char
code), and the value member (the PK of the table) to ST_ID (the PK of the
table).  Opened the form, selected the state in the combo and the data grid
moved the record selector to that state.

Man was THAT easy!  So the combination of everything allows the combo to
just act as a record selector without all of the code required in Access.
Not knowing exactly what is happening, I have to assume that the combo
selecting something causes a record selector pointer in the data set object
to point somewhere.  Since the data grid is using the same data set object,
the data grid displays the newly selected record.

Just a guess of course.  This stuff is way over my head.

But so easy (if I just understood what I was doing).

Cool beans man!

John W. Colby
Colby Consulting
www.ColbyConsulting.com

----------------------------------------------------
Is email taking over your day?  Manage your time with eMailBoss.
Try it free!  http://www.eMailBoss.com





More information about the dba-VB mailing list