Groups | Blog | Home
all groups > dotnet general > march 2006 >

dotnet general : Binding ComboBox


Steve King
3/5/2006 6:53:26 PM
I'm attempting to bind a combobox to store the values in
tblProblems.VersionID and display the Version value from the tblVersions.
The VersionID field is a foreign key to the ID in tblVersions. Currently I
have the combobox displaying the versions in the dropdown which is what I
need but when I select a different version it is displayed for every record
(apparently not bound to the value of VersionID in tblProblems.

Documentation that I have is confusing and doesn't really address my
situation of using the validation table. I routinely use this technique in
Microsoft Access but the control binds very differently.

TABLES
--------------
tblProblems.VersionID (1)

tblVersions.ID (1)
tblVersions.Version (1.0.1)

RELATIONSHIPS
-------------
ProblemsVersionIDColumn = DataSet11.Tables("tblProblems").Columns("VersionID")
VersionsKeyColumn = DataSet11.Tables("tblVersions").Columns("ID")
problemsversions = New DataRelation("problemsversions",
ProblemsVersionIDColumn, VersionsKeyColumn)
DataSet11.Relations.Add(problemsversions)

COMBOBOX PROPERTIES
---------------------
DataSource tblVersions
DisplayMember - Version
ValueMember - ID

DataBindings.SelectedItem (None)
DataBindings.SelectedValue (None)
DataBindings.Text (DataSet11 - tblProblems.VersionID)
--
Cor Ligthert [MVP]
3/6/2006 12:00:00 AM
Steve,

And what do you need?

Cor


"Steve King" <SteveKing@discussions.microsoft.com> schreef in bericht
news:C4D6FD76-0480-4B5C-B0A0-E773E6F09E0F@microsoft.com...
[quoted text, click to view]

Steve King
3/6/2006 10:35:20 AM
when I select a different version it is displayed for every record
(apparently not bound to the value of VersionID in tblProblems.

When I move the form from record to record I expected the relationship to
cause the combobox to display the version number related to the record being
viewd, and it doesn't.

tblProblems.VersionID -> FORM (COMBO) <-- tblVersions.ID (Value),
tblVersions.Version (Display)


--
Steve King


[quoted text, click to view]
Cor Ligthert [MVP]
3/6/2006 7:45:08 PM
Steve,

I thought that this is the part where I never could use the relations.

Can you try this sample.

http://www.vb-tips.com/default.aspx?ID=cb1408ff-030d-4ea8-80b1-af26354b1fa0

This is three deep and using a datagrid, however that is in my opinion a
detail.


Cor

"Steve King" <SteveKing@discussions.microsoft.com> schreef in bericht
news:88A70524-CF59-4B07-9B52-9A0A8C963E1D@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button