开发者

Object sender to control sender?

开发者 https://www.devze.com 2023-03-04 16:45 出处:网络
Is there a way for me to change object s开发者_JS百科ender 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

Is there a way for me to change object s开发者_JS百科ender 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消