Hi I have two tables...

DataSources(id, Type, Name)
DataSourcesTypes(id, TypeDescription)

DataSourcesTypes contains lookup field data that will populate the Type
field in the DataSource table.

I would like to setup a comboBox with the following...
DisplayMember = DataSourcesTypes.TypeDescription
ValueMember = DataSources.Type

The ultimate effect being a form that displays the description in a combo
box but is altering the ID field in the dataSource table for the particular
dataSource being edited.

I understand that a relationship should be setup but I cannot get it to work
?

thanks for any time on this

Sharat Koya

RE: DataBinding to a combo box. by BonnieBerentCMVP

BonnieBerentCMVP
Thu Feb 17 10:35:13 CST 2005

Sharat,

No, you don't need to mess with relationships at all.

First, set the DataSource and members of your Combo:

MyCombo.DataSource = DataSourcesTypes;
MyCombo.DisplayMember = "TypeDescription";
MyCombo.ValueMember = "id";

Then, bind the Combo to your other table:

MyCombo.DataBindings.Add("SelectedValue", DataSource, "id")

That should do the trick.

~~Bonnie


"Sharat Koya" wrote:

> Hi I have two tables...
>
> DataSources(id, Type, Name)
> DataSourcesTypes(id, TypeDescription)
>
> DataSourcesTypes contains lookup field data that will populate the Type
> field in the DataSource table.
>
> I would like to setup a comboBox with the following...
> DisplayMember = DataSourcesTypes.TypeDescription
> ValueMember = DataSources.Type
>
> The ultimate effect being a form that displays the description in a combo
> box but is altering the ID field in the dataSource table for the particular
> dataSource being edited.
>
> I understand that a relationship should be setup but I cannot get it to work
> ?
>
> thanks for any time on this
>
> Sharat Koya
>
>
>
>

Re: DataBinding to a combo box. by Sharat

Sharat
Mon Feb 21 05:30:49 CST 2005

Ah thanks, worked a treat.

"Bonnie Berent [C# MVP]" <BonnieBerentCMVP@discussions.microsoft.com> wrote
in message news:9560F53D-8B28-4B7A-93F0-E373CCBF9530@microsoft.com...
> Sharat,
>
> No, you don't need to mess with relationships at all.
>
> First, set the DataSource and members of your Combo:
>
> MyCombo.DataSource = DataSourcesTypes;
> MyCombo.DisplayMember = "TypeDescription";
> MyCombo.ValueMember = "id";
>
> Then, bind the Combo to your other table:
>
> MyCombo.DataBindings.Add("SelectedValue", DataSource, "id")
>
> That should do the trick.
>
> ~~Bonnie
>
>
> "Sharat Koya" wrote:
>
>> Hi I have two tables...
>>
>> DataSources(id, Type, Name)
>> DataSourcesTypes(id, TypeDescription)
>>
>> DataSourcesTypes contains lookup field data that will populate the Type
>> field in the DataSource table.
>>
>> I would like to setup a comboBox with the following...
>> DisplayMember = DataSourcesTypes.TypeDescription
>> ValueMember = DataSources.Type
>>
>> The ultimate effect being a form that displays the description in a combo
>> box but is altering the ID field in the dataSource table for the
>> particular
>> dataSource being edited.
>>
>> I understand that a relationship should be setup but I cannot get it to
>> work
>> ?
>>
>> thanks for any time on this
>>
>> Sharat Koya
>>
>>
>>
>>



Re: DataBinding to a combo box. by BonnieBerentCMVP

BonnieBerentCMVP
Mon Feb 21 14:55:02 CST 2005

Great! Glad I could help! =)

~~Bonnie

"Sharat Koya" wrote:

> Ah thanks, worked a treat.
>
> "Bonnie Berent [C# MVP]" <BonnieBerentCMVP@discussions.microsoft.com> wrote
> in message news:9560F53D-8B28-4B7A-93F0-E373CCBF9530@microsoft.com...
> > Sharat,
> >
> > No, you don't need to mess with relationships at all.
> >
> > First, set the DataSource and members of your Combo:
> >
> > MyCombo.DataSource = DataSourcesTypes;
> > MyCombo.DisplayMember = "TypeDescription";
> > MyCombo.ValueMember = "id";
> >
> > Then, bind the Combo to your other table:
> >
> > MyCombo.DataBindings.Add("SelectedValue", DataSource, "id")
> >
> > That should do the trick.
> >
> > ~~Bonnie
> >
> >
> > "Sharat Koya" wrote:
> >
> >> Hi I have two tables...
> >>
> >> DataSources(id, Type, Name)
> >> DataSourcesTypes(id, TypeDescription)
> >>
> >> DataSourcesTypes contains lookup field data that will populate the Type
> >> field in the DataSource table.
> >>
> >> I would like to setup a comboBox with the following...
> >> DisplayMember = DataSourcesTypes.TypeDescription
> >> ValueMember = DataSources.Type
> >>
> >> The ultimate effect being a form that displays the description in a combo
> >> box but is altering the ID field in the dataSource table for the
> >> particular
> >> dataSource being edited.
> >>
> >> I understand that a relationship should be setup but I cannot get it to
> >> work
> >> ?
> >>
> >> thanks for any time on this
> >>
> >> Sharat Koya
> >>
> >>
> >>
> >>
>
>
>