473,657 Members | 2,515 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_KeyDow n(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles ToolBar1.KeyDow n

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 1628
Use the following code in your form to handle the keypress event.

Protected Overrides Function ProcessDialogKe y(ByVal keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Right Then
'Move the Panel
Return True
End If
Return MyBase.ProcessD ialogKey(keyDat a)
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_KeyDow n(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles ToolBar1.KeyDow n

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 ProcessDialogKe y(ByVal keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Right Then
'Move the Panel
Return True
End If
Return MyBase.ProcessD ialogKey(keyDat a)
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_KeyDow n(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles ToolBar1.KeyDow n

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
1443
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}, etc. Does it have something to do with {Backspace} being the hot key for going to the previous page? Code: this.cboSearch.KeyDown += new KeyEventHandler(this.cboSearch_KeyDown); private void cboSearch_KeyDown (object sender, KeyEventArgs e)
3
6943
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 ChildForm(); this.AddOwnedForm (child);
3
6438
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 only way to close the FixedToolWindow form is by clicking on the toolbar button again. It's a bit like pressing "Search" on IE's toolbar. BTW why is the ToolBar that comes with VS.NET so ugly? It's like the old style toolbar.
3
9218
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 click on a row (withs will turn blue then) and then click on it again . Now if I press any key the event will fire (except for the arrow keys). I also tried to override the IsInputKey => no luck. I also tried to override the ProcessCmdKey => With...
0
1839
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 function picturebox_keydown in response to the keydown events on the ActiveX control. These can work well. But when I update these codes to vb.net I got a message 'UPGRADE_WARNING: PictureBox event Picture1.KeyDown can't be updated. Click to get more...
0
1011
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, rather then doing what I want it to do, it simply circulates through the buttons on the ToolBar. How can I by pass this? Thanks, Eddie
4
7126
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 System.Windows.Forms.KeyEventArgs) _ Handles ListBox1.KeyUp, ListBox1.KeyDown If e.KeyValue = Keys.PageDown Or e.KeyValue = Keys.PageUp Or e.KeyValue = Keys.End Or e.KeyValue = Keys.Home Then
3
5246
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 handler does not see the combination. Now this control is contained within another control which is contained within another. The top most control does see the CTRL+Z. I can easily pass down the key info, but why does the nested control see...
2
19286
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 have created for this purpose is derived from class UserControl.
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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 we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.