|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to prevent keydown events on toolbarI am trying to move a panel (panel2) around which is inside another panel (panel1). I want the user to be able to use the arrow keys on the keyboard. However when I press either arrow key, focus is set to my toolbar (toolbar1) and you see focus going from pushbutton to pushbutton. I've tried keydown events on mybase, panel1, panel2 and finally only this is working: Private Sub ToolBar1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolBar1.KeyDown If e.KeyCode = Keys.Right Then panel2.location = [etc] End If End Sub However this is not a nice workaround. If the user presses right or left several times in a row or holds down the key, you see the panel moving alright but also the toolbar gets repainted over and over again to a point it can't repaint quickly enough and disappears a moment. So both the panel is moving and the focus is moving over the pushbuttons on the toolbar. Can someone tell me how to tell the toolbar _not_ to catch keydown events and let the panel1, panel2 or mybase or even the form handle this (where it should be in this situation). Help is appreciated! Kind Regards, Martin. Use the following code in your form to handle the keypress event.
Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean If keyData = Keys.Right Then 'Move the Panel Return True End If Return MyBase.ProcessDialogKey(keyData) End Function Hope this helps. Sugan. mart***@hotmail.com wrote: Show quoteHide quote > Dear group, > > I am trying to move a panel (panel2) around which is inside another > panel (panel1). I want the user to be able to use the arrow keys on the > keyboard. > > However when I press either arrow key, focus is set to my toolbar > (toolbar1) and you see focus going from pushbutton to pushbutton. > > I've tried keydown events on mybase, panel1, panel2 and finally only > this is working: > > Private Sub ToolBar1_KeyDown(ByVal sender As Object, ByVal e As > System.Windows.Forms.KeyEventArgs) Handles ToolBar1.KeyDown > > If e.KeyCode = Keys.Right Then > > panel2.location = [etc] > > End If > > End Sub > > However this is not a nice workaround. If the user presses right or > left several times in a row or holds down the key, you see the panel > moving alright but also the toolbar gets repainted over and over again > to a point it can't repaint quickly enough and disappears a moment. > > So both the panel is moving and the focus is moving over the > pushbuttons on the toolbar. > > Can someone tell me how to tell the toolbar _not_ to catch keydown > events and let the panel1, panel2 or mybase or even the form handle > this (where it should be in this situation). > > Help is appreciated! > > Kind Regards, > Martin. Once you've figured out where to put the statue I'm creating for you,
just say so! In other words: thanks! works wonderfully ! Sugan wrote: Show quoteHide quote > Use the following code in your form to handle the keypress event. > > Protected Overrides Function ProcessDialogKey(ByVal keyData As > System.Windows.Forms.Keys) As Boolean > If keyData = Keys.Right Then > 'Move the Panel > Return True > End If > Return MyBase.ProcessDialogKey(keyData) > End Function > > Hope this helps. > > Sugan. > > mart***@hotmail.com wrote: > > Dear group, > > > > I am trying to move a panel (panel2) around which is inside another > > panel (panel1). I want the user to be able to use the arrow keys on the > > keyboard. > > > > However when I press either arrow key, focus is set to my toolbar > > (toolbar1) and you see focus going from pushbutton to pushbutton. > > > > I've tried keydown events on mybase, panel1, panel2 and finally only > > this is working: > > > > Private Sub ToolBar1_KeyDown(ByVal sender As Object, ByVal e As > > System.Windows.Forms.KeyEventArgs) Handles ToolBar1.KeyDown > > > > If e.KeyCode = Keys.Right Then > > > > panel2.location = [etc] > > > > End If > > > > End Sub > > > > However this is not a nice workaround. If the user presses right or > > left several times in a row or holds down the key, you see the panel > > moving alright but also the toolbar gets repainted over and over again > > to a point it can't repaint quickly enough and disappears a moment. > > > > So both the panel is moving and the focus is moving over the > > pushbuttons on the toolbar. > > > > Can someone tell me how to tell the toolbar _not_ to catch keydown > > events and let the panel1, panel2 or mybase or even the form handle > > this (where it should be in this situation). > > > > Help is appreciated! > > > > Kind Regards, > > Martin.
Embedding a newline in a vb.net string constant
convet date format Why does the the program not quit in this case? task manager, app doesn't unload Best way to handle interface and Forms Exe Size Apostrophe Problem - HELP Excel dll on computer whitout offices Visual Basic 2005 - ContextSwitchDeadLock was detected when debugging VB.NET Problem: Setting the Mask and Picture Properties on a CommadBar without "LoadPicture"??? |
|||||||||||||||||||||||