开发者

create mouse down event handller in run time

开发者 https://www.devze.com 2023-02-16 15:10 出处:网络
I write a win app,and in run time i make many controls and locate on my forms,now i want to handell the mouse down event for any control that i create,now how can i do it??it\'s important for me that

I write a win app,and in run time i make many controls and locate on my forms,now i want to handell the mouse down event for any control that i create,now how can i do it??it's important for me that when the mouse down event occerred ,i understand from which c开发者_StackOverflow中文版ontrol is occurred. my controls that i create are picture box. my question is clear?? thanks.


You can write control.MouseDown += SomeMethod; and check the sender parameter in void SomeMethod(object sender, MouseEventArgs e) { ... }.


I would create a selection handler class and then require each of your controls to implement it. SLaks idea sounds good for something not too complex, but as you add more controls to your page a selection handler will be more efficient from both a code maintenance and code execution standpoint.

0

精彩评论

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