Winforms User Controls - How do I bind those to a dataset on the host form

Winforms User Controls - How do I bind those to a dataset on the host form

am 15.04.2008 04:49:37 von Gabe Garza

Hello there,

I have a dataset on a form...I shall call the host form.
I also have a user control with a whole bunch of textboxes and
gridviewcontrols on it. I shall call this the leech form.

I want the controls on the leech form to get bound to a dataset and/or
binding sources that reside on the host form.

At the moment I just pass in the dataset by reference to the user control
but this seems like a bit of a cludge...Does anyone have any thoughts on the
best way to go about doing this?

Thank you kindly for your time
John Sheppard

Re: Winforms User Controls - How do I bind those to a dataset on the host form

am 15.04.2008 05:38:22 von pvdg42

"John Sheppard" wrote in message
news:fu155n02tel@news2.newsguy.com...
> Hello there,
>
> I have a dataset on a form...I shall call the host form.
> I also have a user control with a whole bunch of textboxes and
> gridviewcontrols on it. I shall call this the leech form.
>
> I want the controls on the leech form to get bound to a dataset and/or
> binding sources that reside on the host form.
>
> At the moment I just pass in the dataset by reference to the user control
> but this seems like a bit of a cludge...Does anyone have any thoughts on
> the best way to go about doing this?
>
> Thank you kindly for your time
> John Sheppard
>

You would have to go into your user control and create a mechanism whereby
all data binding properties of the constituent controls are exposed in the
user control. Frankly, IMHO, passing a reference to the dataset sounds much
easier.

Re: Winforms User Controls - How do I bind those to a dataset on the host form

am 15.04.2008 07:56:47 von Gabe Garza

"PvdG42" wrote in message
news:OAlGtoqnIHA.4708@TK2MSFTNGP02.phx.gbl...
> "John Sheppard" wrote in message
> news:fu155n02tel@news2.newsguy.com...
>> Hello there,
>>
>> I have a dataset on a form...I shall call the host form.
>> I also have a user control with a whole bunch of textboxes and
>> gridviewcontrols on it. I shall call this the leech form.
>>
>> I want the controls on the leech form to get bound to a dataset and/or
>> binding sources that reside on the host form.
>>
>> At the moment I just pass in the dataset by reference to the user control
>> but this seems like a bit of a cludge...Does anyone have any thoughts on
>> the best way to go about doing this?
>>
>> Thank you kindly for your time
>> John Sheppard
>>
>
> You would have to go into your user control and create a mechanism whereby
> all data binding properties of the constituent controls are exposed in the
> user control. Frankly, IMHO, passing a reference to the dataset sounds
> much easier.
>

Thank you PvdG42...yes it is easy, I guess I always feel as though there has
to be a better way...I guess I was after reassurance that this is how other
people do it...

One particular problem I'm having with this method is that my binding
sources that reside on my leech form doesn't seem to be happy with the
referenced dataset. Still trying to figure that one out...:(

Thank you
John Sheppard