473,503 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to prevent keydown events on toolbar

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.

Dec 7 '06 #1
2 1618
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.

ma*****@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.
Dec 7 '06 #2
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:
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.

ma*****@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.
Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1421
by: CoderOfBugs | last post by:
I am developing an IE Toolbar that has a combo box. The combox box doesn't fire the KeyDown event when the {Backspace} key is pressed. Very strange. The event fires for {Delete}, {Space}, {CTRL},...
3
6921
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
3
6427
by: 007 | last post by:
I have a FixedToolWindow form that I create and display when the user presses a button on the toolbar. I want to prevent Alt+F4 on the FixedToolWindow form. How do I accomplish this? I want the...
3
9199
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
0
1826
by: Peter | last post by:
I have a VB6 program which can receive Keydown events on an ActiveX control. The ActiveX control can't fire keydown events so I put a picturebox below the ActiveX control. I write codes in...
0
995
by: Eddie | last post by:
Hi All, I'm having a little problem with the KeyDown event handler. I have added a keydown event handler to my Form, but the ToolBar control is overriding it. So say I press the arrow keys,...
4
7118
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As...
3
5236
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
2
19275
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.