473,671 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding a ComboBox in a Windows Form to a Hierarchical DataSet

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
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 20 '05 #1
5 1593
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
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
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1, a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 20 '05 #2
> Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?
Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.
I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I
want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl... Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
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
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in

Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns as its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do it?

Thanks!

--
Greg Dunn


Nov 20 '05 #3
Hi Greg,

Ah sorry, you are after a lookup, right.
Set ComboBox' ValueMamber and DisplayMember to a column from Table2 and
DataSource to Table2
Go to DataBindings and bind Selected Value to Table1.Item_Own er.

That should enable combobox to act like lookup.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:cbnEb.4243 04$ao4.1359496@ attbi_s51...
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?


Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.


I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I
want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl...
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
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
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in

Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns

as its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do it?

Thanks!

--
Greg Dunn



Nov 20 '05 #4
Greg,

You want to fill your Owner table with all the valid vlaues it would be
(complete table scan?) just use a Data Adapter to fill it or whatever you
want.

Then, on your bindings, you want to bind your combo boxes SelectedValue to
your Table1.Item_Own er Property.

This should take care of it.

and on yoru combo box, set your display member to Owner_name and your
valuemember to OwnerID. Thats all it takes.

peace,
cJ
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
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
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1, a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 20 '05 #5
Ah...very easy. Many thanks!

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Greg,

Ah sorry, you are after a lookup, right.
Set ComboBox' ValueMamber and DisplayMember to a column from Table2 and
DataSource to Table2
Go to DataBindings and bind Selected Value to Table1.Item_Own er.

That should enable combobox to act like lookup.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:cbnEb.4243 04$ao4.1359496@ attbi_s51...
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?


Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.


I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl...
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
> 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
> -------
> Owner_ID (primary key)
> Owner_Name
>
>
> I wish to display, on a form designed for maintenance of the data in
Table1,
> a combobox which displays owner names (Table2.Owner_N ame), but

returns as
> its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can
I do
> it?
>
> Thanks!
>
> --
> Greg Dunn
>
>
>



Nov 20 '05 #6

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

Similar topics

5
2601
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 -------
13
4301
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying structure of the datasets, i.e lots of child tables etc, I cannot use bindingcontext
1
2622
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 Products table.
10
1900
by: Richard | last post by:
I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind. However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works .. However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
4
4613
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
0
1559
by: oracle | last post by:
Greetings, I have a combo box that I binded to a data set using text and tags. I want it to display the DRT.Name property and have a DRT.UnitId as a value. this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.drtDataSet1, "DRT.UnitId")); this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.drtDataSet1, "DRT.Name"));
3
7506
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 on. It's a simple program that loads a control onto a form and binds "Foo" against a combobox ("SelectedItem") for it's "Bar" property and a datetimepicker ("Value") for it's "DateTime" property. The DateTimePicker.Visible value is set to...
3
2437
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When the users selects an item from the combo box I'd like the 4 text boxes to get populated with the corresponding item information from the same dataset table row that the combo box is pulling it's info from. Is there an easy way of doing this besides...
1
2232
by: Jim | last post by:
Hi, Trying to implement databinding. I've a dataset with a table, a windows form with typical controls: combobox, datetimepicker, textbox . . . I use what I think is a normal method to establish the bindings: textbox1.databindings.add("text", dataset, table.column) The records displays in the UI(if it exists). I can create an initial record and successfully save to the database.
1
2101
by: GS | last post by:
I am perplexed . I thought it is easy to fix the binding error on cvtDtFrom. I only used the cvtDtFrom a couple of places but I found out the error occurred before form loading. I tried searching in the solution for cvtDtFrom but failed to find the culprit. tried using clue from stack trace, searching for DataGridview and variations of view.datacon... no luck, Even tried searching all files for the sub main, I failed to find...
0
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.