Can anyone help with user controls

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi, can anyone help me with passing values from a user
control to a parent form in a windows application. I have
a button in my user control object that reads a value when
clicked. How do I return that object to the parent form
and trigger an event to update the form?

thanks in advance!
 
Mike said:
Hi, can anyone help me with passing values from a user
control to a parent form in a windows application. I have
a button in my user control object that reads a value when
clicked. How do I return that object to the parent form
and trigger an event to update the form?

I'd personally look at having the control raise an event called 'ValueSet'
or something. Then have the parent form respond to that event by reading the
value and doing whatever you need it to do with it! The value/object itself
could be passed in the event, or the control could expose a public property
to allow the form to read the value.

HTH

Tobin
 
Mike said:
Hi, can anyone help me with passing values from a user
control to a parent form in a windows application. I have
a button in my user control object that reads a value when
clicked. How do I return that object to the parent form
and trigger an event to update the form?

thanks in advance!

Declare a delegate prototype and event for your user control.

When you get the click event and read your value then check to see
whether any delegates have been added to your event and if so then
fire the event.

It is up to the form, then, to add an event handler for this
particular event. You should see your new event in the Properties
page (event tab) for your user control once you add it to the code.

-- TB
 
Back
Top