Referring to a Control's Properties

J

Joe Williams

I am trying to run a function that will determine the back color property of
a control when I click on that control. I have a lot of controls and
therefore I would like to write one generic function that I can call from
each control's OnClick event to get the backcolor property.

However, In each control's OnClick event, the only way I have found to get
the backcolor property is to go me.txtControl.backcolor which requires me to
explicitly name each control. So instead of being able to call a generic
function I would have to change the control name for each control's OnClick
event.

Is there a way a control can refer to itself to get the backcolor property
without specifically naming the control (Similiar to the Me. property for
forms)?

Thanks

joe
 
D

Dirk Goldgar

Joe Williams said:
I am trying to run a function that will determine the back color
property of a control when I click on that control. I have a lot of
controls and therefore I would like to write one generic function
that I can call from each control's OnClick event to get the
backcolor property.

However, In each control's OnClick event, the only way I have found
to get the backcolor property is to go me.txtControl.backcolor which
requires me to explicitly name each control. So instead of being able
to call a generic function I would have to change the control name
for each control's OnClick event.

Is there a way a control can refer to itself to get the backcolor
property without specifically naming the control (Similiar to the Me.
property for forms)?

If it's a control that can receive the focus, clicking on it will make
it the active control, in which case you can use Screen.ActiveControl to
refer to the control. But a label, for example, can't receive the
focus, and so cannot be the active control. Do you have to do this for
controls that can't receive the focus, or is Screen.ActiveControl good
enough for you?
 

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

Top