简体   繁体   中英

Object sender to control sender?

Is there a way for me to change object sender into, say, control sender? What I want in the end is for object sender to tell me the controller count (controller 15, for instance), rather then it tell me "system.project.label, text : 'text here'".

I do have a way around this issue by looking through each controller on a sheet and matching object sender to said controller, but that is a fairly lengthy workaround. I'm curious if anyone knows a way to get sender to report it's control location instead.

Assuming you are talking about the object sender argument of an event handler, then you can always cast it to a control.

if(sender is Control)
{
   var myControl = sender as Control;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM