vb.net中的按钮keypress属性 [英] button keypress property in vb.net
本文介绍了vb.net中的按钮keypress属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在按下按钮1的同时执行在按钮1 click事件中编写的代码.
当我释放按钮时,执行应该停止.
请告诉我可以通过文本框的哪种属性或方法来执行此操作.
谢谢.
解决方案
Anand,
您要执行在button_Click中编写的代码.是否要调用异步调用或同步调用,一旦执行button_Click方法,然后在执行Click方法后返回.
如果不想执行它们,则应改用button_MouseUp方法,MouseUp仅在释放按钮时执行.
您还应该将相同的事件附加到KeyUp,因为用户可能会使用键盘来单击按钮而不是鼠标.
希望您能消除疑问,如果不能,请向我们描述您的功能.
问候
Rushi
看看如何处理MouseDown和MouseUp事件-您可能还需要检查MouseMove或MouseLeave事件,并将代码从Click事件中删除,以使用常规方法. 如果要重复调用该例程,则可能还需要引入一个计时器. ".您应该创建自己的自定义控件,就像按钮一样,但是要使用较低级的键盘和鼠标事件来实现此类事件.不要从Button
派生您的控件类,而从Control
派生它.
—SA
I want to execute the code written in button 1 click event whilst button 1 is pressed.
When I release the button then execution should stop.
Please give me by which property or method of textbox I can perform this.
Thank you.
解决方案
Anand,
You want to execute code written in button_Click. Do you want to call an Asynchronous call or Synchronous call, once you execute button_Click method then it return after executing Click method.
If you don''t want to execute them then you should use button_MouseUp method instead, MouseUp only executes when button released.
You should also attach same Event to KeyUp as it may possible that user use keyboard to click button not mouse.
I hope you clear your doubt, if not please describe us what is your functionality.
Regards
Rushi
Look at handling the MouseDown and MouseUp events - you may also want to check for MouseMove or MouseLeave events and remove your code from the Click event to a general method.
You may also need to introduce a timer if you want the routine called repeatedly.
You cannot do it with a standard button, because a button does not expose events like "PressedDown" and "Released". You should create your own custom control looking like button but implementing such events using lower-level keyboard and mouse events. Don''t derive your control class fromButton
, derive it fromControl
.
—SA
这篇关于vb.net中的按钮keypress属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文