Scroll Bar hogging focus
-
Hi, I'm creating a control, I do painting on the form and it has 1 scroll bar control, no other controls on it. I have a keyDown/keyUp handler and they work just fine until I hit the arrow keys, then the scroll bar grabs the key focus and I can't get it back. How can I stop the scrollbar from getting the key focus, I don't want it to be able to grab the key focus at all. Thanks! -- Rocky Dean Pulley
-
Hi, I'm creating a control, I do painting on the form and it has 1 scroll bar control, no other controls on it. I have a keyDown/keyUp handler and they work just fine until I hit the arrow keys, then the scroll bar grabs the key focus and I can't get it back. How can I stop the scrollbar from getting the key focus, I don't want it to be able to grab the key focus at all. Thanks! -- Rocky Dean Pulley
One common way of handling this sort of issue is to subscribe to the Focus events (GotFocus, LostFocus). When the focus changes, detect whether the focus fits with your plan (using the Focused property, if needed). Then, adjust the focus back to where you want it. Of course, you'll need to test things out. It may be that the auto-adjustement of focus has side effects that will take extra effort to work around. John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek. -
One common way of handling this sort of issue is to subscribe to the Focus events (GotFocus, LostFocus). When the focus changes, detect whether the focus fits with your plan (using the Focused property, if needed). Then, adjust the focus back to where you want it. Of course, you'll need to test things out. It may be that the auto-adjustement of focus has side effects that will take extra effort to work around. John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.Thanks, but it looks like neither the UserControl class nor the VScrollBar class has these events available. -- Rocky Dean Pulley
-
Thanks, but it looks like neither the UserControl class nor the VScrollBar class has these events available. -- Rocky Dean Pulley
The UserControl definitely has GotFocus and LostFocus. If you are looking only in the property editor of VS, you might not see them. But, the are available if you write the code yourself:
userControl.GotFocus += new ....
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek. -
The UserControl definitely has GotFocus and LostFocus. If you are looking only in the property editor of VS, you might not see them. But, the are available if you write the code yourself:
userControl.GotFocus += new ....
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.thanks, that worked. -- Rocky Dean Pulley
-
thanks, that worked. -- Rocky Dean Pulley
Great! John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.