Data bindings with relations

G

Guest

Hi,
I'm building a test application I call JukeBox, with an Access DB working
with Ole Db. In there I have an Albums table and an Artists table. In the
first I have an ArtistID column that points to an ID in the Artists table.

Now what I'd like to do would be to have a datagrid that's bound to the
Albums table, but to have a combobox that would contain all the entries of
the Artists table, and that would somehow be bound to the ArtistID entry in
the Albums table (i.e.: when an album is selected in the datagrid, the
corresponding artist is selected in the combo, and when an artist is selected
in the combom the change is affected to the datagrid).

Now, using this:
comboArtists->DataSource = dtAlbums->DefaultView;
comboArtists->DisplayMember = "Artists.Name";
comboArtists->ValueMember = "ArtistID";
I can get the combo to display all the artists that are used in the Albums
table, but that's not really what I want.

Is there a simple way to do this or would I have to do it manually with the
"Changed" events of the datagrid and the combobox?
 
E

Earl

One way to do it would be to set up your Select statement for the datagrid
so that the WHERE clause reflects what you selected in your combo (so that
it changes every time your SelectedValue changes). I don't think that's the
"simple" method you are looking for however.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top