无法取消选择 NumericUpDown?
如果您创建一个新的 C# 项目并将 NumericUpDown 放在表单(甚至是文本框)上,是否无法取消选择?
目前,我的应用程序有一个可滚动容器,当用户选择 NumericUpDown 时,他或她无法取消选择它。然后,当尝试使用鼠标上的滚轮进行任何操作时,它会滚动 NumericUpDown 的值。
理想情况下,当用户单击表单上的空白点时,它将选择该表单并取消选择 NumericUpDown。或者一般禁用 NumericUpDown 上的鼠标滚轮滚动(也不知道如何执行此操作)。 NumericUpDown 包含不会经常更改的数据,因此它根本不会对用户产生太大影响。
If you make a new C# project and place a NumericUpDown on the form (or even a textbox for that matter) is it impossible to deselect?
Currently my application has a scrollable container and when a user selects a NumericUpDown he or she cannot deselect it. Then when trying to use the scrollwheel on the mouse for anything, it scrolls the value of the NumericUpDown.
Ideally, when the user clicked in a blank spot on the form it would select the form and deselect the NumericUpDown. Either that or disable mouse-wheel scrolling on the NumericUpDown in general (not sure how to do this either). The NumericUpDown's contain data that is not bound to change often, so it would not really impact the user by that much at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要禁用
NumericUpDown
上的鼠标滚轮滚动,您需要创建自己的后代控件来重写OnMouseWheel
事件,并在表单上使用自定义控件。要回答您有关控制焦点的问题,我相信您还需要在表单上至少有一个其他控件来移交焦点。
To disable the mouse wheel scrolling on a
NumericUpDown
you'd need to create your own descendant control that overrides theOnMouseWheel
event, and use the custom control on your form.To answer your question about control Focus, I believe you would need to have at least one other control on the form to hand off the Focus too.
将标签添加到表单并清除其
Text
属性。这将为您留下一个看不到但仍可以获得焦点的标签。在表单的
Click
事件中,调用以下代码将焦点设置到标签:Add a Label to your form and clear its
Text
property. This will leave you with a Label that can't be seen but can still receive focus.On your form's
Click
event, call this code to set the focus to the Label: