Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by Miha
Miha
Thu Dec 18 13:43:19 CST 2003
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_Owner.
That should enable combobox to act like lookup.
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
"Greg Dunn" <MyLists@gregdunn.com> wrote in message
news:cbnEb.424304$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_Owner 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:eodWtZZxDHA.3224@tk2msftngp13.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" <MyLists@gregdunn.com> wrote in message
> > news:SjmEb.424031$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_Name), but returns
> as
> > > its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I
> do
> > > it?
> > >
> > > Thanks!
> > >
> > > --
> > > Greg Dunn
> > >
> > >
> > >
> >
> >
>
>