473,471 Members | 4,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Control.KeyDown Problem

Hi,

Why don't UserControl's received Key events for the arrow keys? Further,
when a user control is added to a Form, why does the form stop receiving Key
events for the arrow keys? I have tried setting IsInputKey(Keys.Left,
Keys.Right, Keys.Up, Keys.Down), but that doesn't work.

Regards,
Jerome.
Nov 13 '05 #1
3 10041
"Jerome Terry" <jt****@navsim.com> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
Why don't UserControl's received Key events for the arrow keys? Further,
when a user control is added to a Form, why does the form stop receiving Key events for the arrow keys? I have tried setting IsInputKey(Keys.Left,
Keys.Right, Keys.Up, Keys.Down), but that doesn't work.


Works for me, but my control has a scrollbar, and that also picks them up :(

See:
news:bf**********@linux01.dannytuppeny.com

My code looks like:

[constructor]
this.KeyDown += new KeyEventHandler(Event_KeyDown);

[then]
public void Event_KeyDown(object sender, KeyEventArgs e)
{

// 37, 38, 39, 40, left, up, right, down
switch ((int)e.KeyCode)
{

case 37:
((Message)this.Messages[this.SelectedIndex]).Expanded = false;
break;

case 39:
((Message)this.Messages[this.SelectedIndex]).Expanded = true;
break;

case 38:
this.SelectedIndex--;
break;

case 40:
this.SelectedIndex++;
break;

}

this.Invalidate();

}
Nov 13 '05 #2
"Jerome Terry" <jt****@navsim.com> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
Hi,

Why don't UserControl's received Key events for the arrow keys? Further,
when a user control is added to a Form, why does the form stop receiving Key events for the arrow keys? I have tried setting IsInputKey(Keys.Left,
Keys.Right, Keys.Up, Keys.Down), but that doesn't work.


Well, I've fixed mine, or gotten it to the same stage as you. KeyDown works
for character keys, but not cursor keys. My scrollbar seems to have stopped
stealing the focus, but I really need cursour keys to work :O(
--
Daisy The Cow
Now playing: Dannii Minogue - I Begin To Wonder
Nov 13 '05 #3
"Daisy" <da***@nospam.oops> wrote in message
news:bf**********@linux01.dannytuppeny.com...
<snip>

Here you go

http://www.ondotnet.com/pub/a/dotnet...ys.html?page=2

Seems to get cursor keys, we can use KeyUp, or ProcessDialogKey

Worth a try...
--
Daisy The Cow
Now playing: Pink - Family Portrait
Nov 13 '05 #4

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

Similar topics

3
by: Peter Verburgh | last post by:
Is there an easy way to capture the keypress - keydown events from a LABEL control ? Standard the control doesn't handle these events. The label control inherits from the control class , and this...
3
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...
3
by: Keith Smith | last post by:
Is there an easy way to make the {Enter} key take the cursor to the next control without using a KeyDown event on each control?
6
by: Barguast | last post by:
When a control's 'Click' event is triggered, is there a way I can test whether the CTRL / Alt / Shift keys are pressed as well? I've thought about capturing KeyDown events before the click but this...
9
by: Woody Splawn | last post by:
On a winform, how do I trap for the user pressing Control Delete? I thought perhaps something like the following in the keydown event of the grid, but the code below does not work. If e.KeyCode...
0
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...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
0
by: ghost | last post by:
i have a main form, with user controls populating it. i'm trying to capture a keyevent for the control that's populating the form but it never fires that event. the main form's keypreview...
0
by: 17beach | last post by:
Control.KeyDown, C#.NET I have a user control with several controls on it. I had the same code in all the controls to call the Winhelp or DO SOME STUFF. The code basically captured the F1 Key...
4
by: boopsboops | last post by:
Hi thescripts people, I hope I'm in the right forum for Visual Basic Dotnet (VS 2005). I am trying to make a custom control in which you can nudge a point around using the arrow keys. Actually,...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.