gpt4 book ai didi

c# - .Net 形式焦点

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:13 26 4
gpt4 key购买 nike

我有一个包含多个控件的 .net 表单。文本框、标签...当表单显示在屏幕上时,文本框默认获得焦点。当我尝试使用鼠标滚轮滚动表单时,滚动消息基本上会转到文本框,因此表单不会滚动..

我试过设置

textbox.capture = false
form.capture = true;
form.focus();

但似乎没有什么能把注意力从文本框上移开。关于如何强制表单获取鼠标事件而不是它的控件的任何线索??

最佳答案

MSDN documentation对于 Control.Focus() 状态:

[...]

A control can be selected and receive input focus if all the following are true: the Selectable value of ControlStyles is set to true, it is contained in another control, and all its parent controls are both visible and enabled.

The Windows Forms controls in the following list are not selectable. Controls derived from these controls are also not selectable.

  • Panel
  • GroupBox
  • PictureBox
  • ProgressBar
  • Splitter
  • Label
  • LinkLabel (when there is no link present in the control)

NoteNote:

Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.


关于c# - .Net 形式焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1499665/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com