one more question before i give up

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

    one more question before i give up

    hi yet again (slowly going crazy here),

    when i press enter......the keypress event doesn't get fired....anyone has a
    clue as for why this is.....i've been looking in MSDN and they do exactly
    what I did....and they claim it works??!!

    well anyway if anyone has any idea why they keypress event (nor the keydown
    event for that matter) doesn't get fired when i press enter???

    thanks


  • Morten Wennevik

    #2
    Re: one more question before i give up

    When using text boxes and buttons, the parent form may not receive
    keypresses.
    There may be some override method for this.

    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

    Comment

    • dawn

      #3
      Re: one more question before i give up

      Ok,

      So now I put the KeyPress event on all my buttons....and it still works fine
      for every key.....except for the enter keystroke


      "Morten Wennevik" <MortenWennevik @hotmail.com> schreef in bericht
      news:opryffvmvj hntkfz@localhos t...[color=blue]
      > When using text boxes and buttons, the parent form may not receive
      > keypresses.
      > There may be some override method for this.
      >
      > --
      > Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/[/color]


      Comment

      • 100

        #4
        Re: one more question before i give up

        Hi,
        KeyPress event is generated only for character keys. *enter* key is not
        considered as so.
        If you want to catch pressing of *enter* key you have to use KeyDown/Up
        events

        HTH
        B\rgds
        100

        "dawn" <dawn4715@hotma il.com> wrote in message
        news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=blue]
        > hi yet again (slowly going crazy here),
        >
        > when i press enter......the keypress event doesn't get fired....anyone has[/color]
        a[color=blue]
        > clue as for why this is.....i've been looking in MSDN and they do exactly
        > what I did....and they claim it works??!!
        >
        > well anyway if anyone has any idea why they keypress event (nor the[/color]
        keydown[color=blue]
        > event for that matter) doesn't get fired when i press enter???
        >
        > thanks
        >
        >[/color]


        Comment

        • 100

          #5
          Re: one more question before i give up

          Hi Morten,
          "Morten Wennevik" <MortenWennevik @hotmail.com> wrote in message
          news:opryffvmvj hntkfz@localhos t...[color=blue]
          > When using text boxes and buttons, the parent form may not receive
          > keypresses.
          > There may be some override method for this.[/color]

          Set form's *KeyPreview* property to *true*.

          HTH
          B\rgds
          100


          Comment

          • dawn

            #6
            Re: one more question before i give up

            it is set to true......and it works fine for every button
            (spacebar.....d igits...) but NOT for enter
            "100" <100@100.com> schreef in bericht
            news:OWL$705pDH A.708@TK2MSFTNG P10.phx.gbl...[color=blue]
            > Hi Morten,
            > "Morten Wennevik" <MortenWennevik @hotmail.com> wrote in message
            > news:opryffvmvj hntkfz@localhos t...[color=green]
            > > When using text boxes and buttons, the parent form may not receive
            > > keypresses.
            > > There may be some override method for this.[/color]
            >
            > Set form's *KeyPreview* property to *true*.
            >
            > HTH
            > B\rgds
            > 100
            >
            >[/color]


            Comment

            • dawn

              #7
              Re: one more question before i give up

              I've tried using KeyDown event as well......but it doesn't trigger either
              when i press *enter*
              "100" <100@100.com> schreef in bericht
              news:eiV2G05pDH A.2488@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Hi,
              > KeyPress event is generated only for character keys. *enter* key is not
              > considered as so.
              > If you want to catch pressing of *enter* key you have to use KeyDown/Up
              > events
              >
              > HTH
              > B\rgds
              > 100
              >
              > "dawn" <dawn4715@hotma il.com> wrote in message
              > news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=green]
              > > hi yet again (slowly going crazy here),
              > >
              > > when i press enter......the keypress event doesn't get fired....anyone[/color][/color]
              has[color=blue]
              > a[color=green]
              > > clue as for why this is.....i've been looking in MSDN and they do[/color][/color]
              exactly[color=blue][color=green]
              > > what I did....and they claim it works??!!
              > >
              > > well anyway if anyone has any idea why they keypress event (nor the[/color]
              > keydown[color=green]
              > > event for that matter) doesn't get fired when i press enter???
              > >
              > > thanks
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • dawn

                #8
                Re: one more question before i give up

                and like i said......on the MSDN page

                frlrfsystemwind owsformskeypres seventargsclass topic.asp

                they use KeyPress event to catch *enter*

                i'm really puzzled here
                "100" <100@100.com> schreef in bericht
                news:eiV2G05pDH A.2488@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Hi,
                > KeyPress event is generated only for character keys. *enter* key is not
                > considered as so.
                > If you want to catch pressing of *enter* key you have to use KeyDown/Up
                > events
                >
                > HTH
                > B\rgds
                > 100
                >
                > "dawn" <dawn4715@hotma il.com> wrote in message
                > news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=green]
                > > hi yet again (slowly going crazy here),
                > >
                > > when i press enter......the keypress event doesn't get fired....anyone[/color][/color]
                has[color=blue]
                > a[color=green]
                > > clue as for why this is.....i've been looking in MSDN and they do[/color][/color]
                exactly[color=blue][color=green]
                > > what I did....and they claim it works??!!
                > >
                > > well anyway if anyone has any idea why they keypress event (nor the[/color]
                > keydown[color=green]
                > > event for that matter) doesn't get fired when i press enter???
                > >
                > > thanks
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Bob Powell [MVP]

                  #9
                  Re: one more question before i give up

                  Override ProcessCmdKey in your form.

                  --
                  Bob Powell [MVP]
                  C#, System.Drawing

                  The October edition of Well Formed is now available.
                  Find out how to use DirectX in a Windows Forms control


                  Answer those GDI+ questions with the GDI+ FAQ


                  Read my Blog at http://bobpowelldotnet.blogspot.com

                  "dawn" <dawn4715@hotma il.com> wrote in message
                  news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=blue]
                  > hi yet again (slowly going crazy here),
                  >
                  > when i press enter......the keypress event doesn't get fired....anyone has[/color]
                  a[color=blue]
                  > clue as for why this is.....i've been looking in MSDN and they do exactly
                  > what I did....and they claim it works??!!
                  >
                  > well anyway if anyone has any idea why they keypress event (nor the[/color]
                  keydown[color=blue]
                  > event for that matter) doesn't get fired when i press enter???
                  >
                  > thanks
                  >
                  >[/color]


                  Comment

                  • Bob Powell [MVP]

                    #10
                    Re: one more question before i give up

                    Forgot the code...

                    protected override bool ProcessCmdKey(r ef Message msg, Keys keyData)

                    {

                    if(keyData==Key s.Enter)

                    {

                    MessageBox.Show ("Enter pressed!");

                    return true;

                    }

                    return base.ProcessCmd Key (ref msg, keyData);

                    }


                    --
                    Bob Powell [MVP]
                    C#, System.Drawing

                    The October edition of Well Formed is now available.
                    Find out how to use DirectX in a Windows Forms control


                    Answer those GDI+ questions with the GDI+ FAQ


                    Read my Blog at http://bobpowelldotnet.blogspot.com

                    "dawn" <dawn4715@hotma il.com> wrote in message
                    news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=blue]
                    > hi yet again (slowly going crazy here),
                    >
                    > when i press enter......the keypress event doesn't get fired....anyone has[/color]
                    a[color=blue]
                    > clue as for why this is.....i've been looking in MSDN and they do exactly
                    > what I did....and they claim it works??!!
                    >
                    > well anyway if anyone has any idea why they keypress event (nor the[/color]
                    keydown[color=blue]
                    > event for that matter) doesn't get fired when i press enter???
                    >
                    > thanks
                    >
                    >[/color]


                    Comment

                    • dawn

                      #11
                      Re: one more question before i give up

                      Thanks a bunch,

                      works like a charm now.

                      Thank GOD!!!! :-)))))
                      "Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > schreef in bericht
                      news:#k7k295pDH A.2528@TK2MSFTN GP12.phx.gbl...[color=blue]
                      > Forgot the code...
                      >
                      > protected override bool ProcessCmdKey(r ef Message msg, Keys keyData)
                      >
                      > {
                      >
                      > if(keyData==Key s.Enter)
                      >
                      > {
                      >
                      > MessageBox.Show ("Enter pressed!");
                      >
                      > return true;
                      >
                      > }
                      >
                      > return base.ProcessCmd Key (ref msg, keyData);
                      >
                      > }
                      >
                      >
                      > --
                      > Bob Powell [MVP]
                      > C#, System.Drawing
                      >
                      > The October edition of Well Formed is now available.
                      > Find out how to use DirectX in a Windows Forms control
                      > http://www.bobpowell.net/currentissue.htm
                      >
                      > Answer those GDI+ questions with the GDI+ FAQ
                      > http://www.bobpowell.net/gdiplus_faq.htm
                      >
                      > Read my Blog at http://bobpowelldotnet.blogspot.com
                      >
                      > "dawn" <dawn4715@hotma il.com> wrote in message
                      > news:gCNrb.1634 0$4L3.443510@ph obos.telenet-ops.be...[color=green]
                      > > hi yet again (slowly going crazy here),
                      > >
                      > > when i press enter......the keypress event doesn't get fired....anyone[/color][/color]
                      has[color=blue]
                      > a[color=green]
                      > > clue as for why this is.....i've been looking in MSDN and they do[/color][/color]
                      exactly[color=blue][color=green]
                      > > what I did....and they claim it works??!!
                      > >
                      > > well anyway if anyone has any idea why they keypress event (nor the[/color]
                      > keydown[color=green]
                      > > event for that matter) doesn't get fired when i press enter???
                      > >
                      > > thanks
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      Working...