sending a control as parameter - they may be several different controls but all have same property..

  • Thread starter Thread starter Amos
  • Start date Start date
A

Amos

I have several controls (textboxes, comboboxes, etc...) and, on an event,
I'd like to change the forecolor property of each one of these. Instead of
writing this.myControl.Forecolor = Color.Black on each event of every
control, I'd like to call a method, with a control as parameter, that does
that. Since this new method will have to work with all these controls (they
all have the forecolor property), what whould the parameter type be?

Thanks again.
 
Amos said:
I have several controls (textboxes, comboboxes, etc...) and, on an event,
I'd like to change the forecolor property of each one of these. Instead of
writing this.myControl.Forecolor = Color.Black on each event of every
control, I'd like to call a method, with a control as parameter, that does
that. Since this new method will have to work with all these controls (they
all have the forecolor property), what whould the parameter type be?

Control, as that will be the eventual ancestor type of all controls,
and has a ForeColor property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top