.Net form focus

I have a .net form with multiple controls. Text box, labels ... When the form is displayed on the screen, the text box is focused on focus by default. When I try to scroll the form using the mouse scroll wheel, the scroll messages mostly go to the textbox and hence the form won't scroll.

I tried setting

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

      

But nothing seems to be paying attention to the textbox. Any hint on how to get the form to receive mouse events rather than control it.

+2


source to share


1 answer


MSDN documentation for Control.Focus()

states:



[...]

You can select and accept control of input focus if all of the following are true: The selectable ControlStyles is true, it is contained in another control, and all of its parent controls are visible and enabled.

Windows Forms controls do not fit in the following list. Controls derived from these controls also cannot be selected.

  • Panel
  • GroupBox
  • PictureBox
  • ProgressBar
  • Separator
  • Label
  • LinkLabel (if there is no link in the control)

NoteNote:

Focus

is a low-level technique primarily intended for user control authors. Instead, application programmers should use a method for either child controls, or a method for forms. Select

ActiveControl

Activate


+2


source







All Articles