473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Binding a ComboBox to a relationship

I think that my problem is similar to the one entitled
"Subject: Complicated Data Binding Question" of 7/2/2005

Simply:
I have a pair of combo (dropdown List) boxes that I want to display data in
a parent/child relationship

This is easy to do with dataGrid controls ( Where m_Families is a strongly
typed dataset with 2 tables, Parents and children and a forign key
relationship between them)
-----------------------------------------------------------
DataGridParents.DataSource = m_Families.Parents

DataGridChildren.DataSource = m_Families.Parents
DataGridChildren.DataMember = m_Families.Relations(0).RelationName
-------------------------------------------------------

I cannot see how to do it for Combos. The best I can come up with is to
hadle the position changed event on the binding context of the parent table
and set the child combobox's datasource to the child rows of the current row.
---------------------------------------------------------------
With Me.ComboBoxParents
.DataSource = m_Families.Parents
.DisplayMember = "Name"
.ValueMember = "ID"
End With

AddHandler
Me.BindingContext(m_Families.Parents).PositionChan ged, AddressOf
PositionChanged

Private Sub PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

With Me.ComboBoxChildren

.DataSource =
CType(CType(Me.BindingContext(m_Families.Parents). Current, DataRowView).Row,
DataRow).GetChildRows(m_Families.Relations(0))
.DisplayMember = "Name"
.ValueMember = "ID"
End With
End Sub
---------------------------------------------------------------
I guess that the datagrid must do something similar to this behind the
scenes and I was expecting to get it for free

The problem is then that selecting an item in the child comboBox doesn't
seem to affect the position of the binging context for the child table as it
does when you use datagrids.

What am I missing please

Ben
Jul 22 '05 #1
0 1308

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
5
by: Greg Dunn | last post by:
I have two tables in a parent-child relationship. Details on the tables are as shown below: Table1 ------- Item_ID (primary key) Item_Owner (foreign key to Table2) Table2 -------
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
3
by: amber | last post by:
Hello, I have 6 comboboxes, that I thought I could bind to the same datasource, and have them display different 'selectedvalue's', but apparently I can't... My code is as follows: dim drv as...
0
by: Ben Reese | last post by:
I think that my problem is similar to the one entitled "Subject: Complicated Data Binding Question" of 7/2/2005 Simply: I have a pair of combo (dropdown List) boxes that I want to display data...
3
by: Steve King | last post by:
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. ...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
3
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
New to databinding in vs2005, I always did it manually in 2003. I have no problem loading comboboxes, and a change in that combobox changes the data in the textboxes but I can not figure out a way...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.