Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Stealing focus?</h1> <p>Consider if stealing focus is really the right way to solve your problem. It's quite tempting because the focus/non-focus difference is so obvious, and it's seems so easy. But it can quickly turn into a mess.</p> <p>Imagine you're using a third party component that steals focus sometimes when it's not supposed to. Annoyed, you'd write some code to grab focus back. Problem solved, not? But now instead of one, there's two components that are inappropriately stealing focus. And in the end, the user will be the victim of this focus war.</p> <h1>Subscribe to the <code>TextBox</code> events instead</h1> <p>Right now you're listening for events on the <code>Panel</code>. Another way of getting the <code>Panel</code> to react to the <code>MouseWheel</code> events is by instead subscribing to the appropriate event of the <code>Textbox</code> on your form, or even subscribe to the event for all controls on your form.</p> <p>Then in your handler, check to see if the mouse is within the bounds of the <code>Panel</code>. If so, instruct the panel to scroll. Don't forget to propagate the mouse event if necessary.</p> <p><strong>EDIT</strong></p> <p>Additional information:</p> <ul> <li>Documentation for <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousewheel.aspx" rel="nofollow">the <code>MouseWheel</code> event</a></li> <li>Code sample for <a href="http://www.codeproject.com/Articles/11014/How-to-route-events-in-a-Windows-Forms-application" rel="nofollow">subscribing to events</a></li> <li>Documentation on <a href="http://msdn.microsoft.com/en-us/library/aa983610%28v=vs.71%29.aspx" rel="nofollow">event handling in Windows Forms</a></li> </ul> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload