Control.KeyDown Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerome Terry

    #1

    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.


  • Daisy

    #2
    Re: Control.KeyDown Problem

    "Jerome Terry" <jterry@navsim. com> wrote in message
    news:eqIzvbHTDH A.2460@TK2MSFTN GP10.phx.gbl...[color=blue]
    > 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[/color]
    Key[color=blue]
    > events for the arrow keys? I have tried setting IsInputKey(Keys .Left,
    > Keys.Right, Keys.Up, Keys.Down), but that doesn't work.[/color]

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

    See:
    news:bf5ff6$8ju $1@linux01.dann ytuppeny.com

    My code looks like:

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

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

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

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

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

    case 38:
    this.SelectedIn dex--;
    break;

    case 40:
    this.SelectedIn dex++;
    break;

    }

    this.Invalidate ();

    }


    Comment

    • Daisy

      #3
      Re: Control.KeyDown Problem

      "Jerome Terry" <jterry@navsim. com> wrote in message
      news:eqIzvbHTDH A.2460@TK2MSFTN GP10.phx.gbl...[color=blue]
      > 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[/color]
      Key[color=blue]
      > events for the arrow keys? I have tried setting IsInputKey(Keys .Left,
      > Keys.Right, Keys.Up, Keys.Down), but that doesn't work.[/color]

      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


      Comment

      • Daisy

        #4
        Re: Control.KeyDown Problem

        "Daisy" <daisy@nospam.o ops> wrote in message
        news:bf6pd1$ij3 $1@linux01.dann ytuppeny.com...
        <snip>

        Here you go

        Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology


        Seems to get cursor keys, we can use KeyUp, or ProcessDialogKe y

        Worth a try...
        --
        Daisy The Cow
        Now playing: Pink - Family Portrait


        Comment

        Working...