473,399 Members | 3,038 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,399 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
Nov 22 '05 #1
0 954

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

Similar topics

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...
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...
16
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.