Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Using Function Keys

Using Function Keys

Scheduled Pinned Locked Moved C#
csharp
20 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Abhijit Jana

    Try with this :

    if (e.KeyCode == Keys.F1)
    DoSomething();

    Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

    K Offline
    K Offline
    khosnur
    wrote on last edited by
    #5

    thank u very much.let me check

    1 Reply Last reply
    0
    • A Abhijit Jana

      Try with this :

      if (e.KeyCode == Keys.F1)
      DoSomething();

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      K Offline
      K Offline
      khosnur
      wrote on last edited by
      #6

      Dear Abhijit, Which MDI's event i will use?I use KeyDown event and i wrote: if(e.KeyCode==Keys.F1) { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); } Form is opened only one time.When i close and again press F1 the form is not coming. would u help me...

      A K 2 Replies Last reply
      0
      • K khosnur

        Dear Abhijit, Which MDI's event i will use?I use KeyDown event and i wrote: if(e.KeyCode==Keys.F1) { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); } Form is opened only one time.When i close and again press F1 the form is not coming. would u help me...

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #7

        You need to use ProcessKeyMessage Check It[^]

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        K 2 Replies Last reply
        0
        • A Abhijit Jana

          Try with this :

          if (e.KeyCode == Keys.F1)
          DoSomething();

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #8

          Why?


          Panic, Chaos, Destruction. My work here is done.

          A 1 Reply Last reply
          0
          • K khosnur

            thank you very much for ur reply. i using this way but its not working.would u help me: if(e.KeyCode.ToString()"F1") { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); }

            N Offline
            N Offline
            Nagy Vilmos
            wrote on last edited by
            #9

            Use google, or bing, and look for ShortcutKeys for crisake! In the designer, menu command, property ShortcutKeys set it. JOB DONE. Stop faffing about.


            Panic, Chaos, Destruction. My work here is done.

            1 Reply Last reply
            0
            • A Abhijit Jana

              You need to use ProcessKeyMessage Check It[^]

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              K Offline
              K Offline
              khosnur
              wrote on last edited by
              #10

              thanks for ur reply

              1 Reply Last reply
              0
              • K khosnur

                Dear Coders, I building a windows application using C#.I build a MDI.MDI has menu.i need when i press like F1(function keys) a specific form will open.This way i want to use F1...F12.Which event and how i do that. Any suggestion is appreciated.Thanks in Advance. Shafik

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                In the MDI form, create a menu item for each child form and assign keyboard shortcuts to the items.

                K 1 Reply Last reply
                0
                • A Abhijit Jana

                  You need to use ProcessKeyMessage Check It[^]

                  Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                  K Offline
                  K Offline
                  khosnur
                  wrote on last edited by
                  #12

                  Sorry i think i am a rubbish programmer. i cant implement.would u tell me how i start

                  1 Reply Last reply
                  0
                  • L Lost User

                    In the MDI form, create a menu item for each child form and assign keyboard shortcuts to the items.

                    K Offline
                    K Offline
                    khosnur
                    wrote on last edited by
                    #13

                    thanks.but i want to use Function keys

                    A L 2 Replies Last reply
                    0
                    • K khosnur

                      Dear Abhijit, Which MDI's event i will use?I use KeyDown event and i wrote: if(e.KeyCode==Keys.F1) { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); } Form is opened only one time.When i close and again press F1 the form is not coming. would u help me...

                      K Offline
                      K Offline
                      khosnur
                      wrote on last edited by
                      #14

                      thanks abhijit i soled the problem.just done below: //KeyPreview property should be true if(e.KeyCode==Keys.F1) { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); } Shafik

                      A 1 Reply Last reply
                      0
                      • N Nagy Vilmos

                        Why?


                        Panic, Chaos, Destruction. My work here is done.

                        A Offline
                        A Offline
                        Abhijit Jana
                        wrote on last edited by
                        #15

                        Nagy Vilmos wrote:

                        Why?

                        I didn't get you.

                        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                        N 1 Reply Last reply
                        0
                        • K khosnur

                          thanks abhijit i soled the problem.just done below: //KeyPreview property should be true if(e.KeyCode==Keys.F1) { frmAllCheckInformation objfrmAllCheckInformation=new frmAllCheckInformation(); objfrmAllCheckInformation.ShowDialog(); } Shafik

                          A Offline
                          A Offline
                          Abhijit Jana
                          wrote on last edited by
                          #16

                          That's Great !:thumbsup:

                          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                          1 Reply Last reply
                          0
                          • A Abhijit Jana

                            Nagy Vilmos wrote:

                            Why?

                            I didn't get you.

                            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                            N Offline
                            N Offline
                            Nagy Vilmos
                            wrote on last edited by
                            #17

                            The example is right, but the concept being encouraged is not. There should be commands that launch the forms in this case, and how it is called shouldn't be hard coded beyond the minimum. The command class allows for a short cut key to be associated and that should provide the nescessary access. Overriding the keybouard handler is really too low level for what is already provided by the framework.


                            Panic, Chaos, Destruction. My work here is done.

                            A 1 Reply Last reply
                            0
                            • K khosnur

                              thanks.but i want to use Function keys

                              A Offline
                              A Offline
                              Alan N
                              wrote on last edited by
                              #18

                              Hey, This has gone on long enough. What people are trying to tell you is to just assign a function key as a short cut key. These assignments are usually done through the designer but example code is this.MyMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1; . Alan.

                              1 Reply Last reply
                              0
                              • K khosnur

                                thanks.but i want to use Function keys

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #19

                                Please try out something on your own before posting so many questions. You can assign function keys as shortcut keys for menu items in the form designer. Select the menu item in the designer and look for the Shortcut property in the Property Explorer window.

                                1 Reply Last reply
                                0
                                • N Nagy Vilmos

                                  The example is right, but the concept being encouraged is not. There should be commands that launch the forms in this case, and how it is called shouldn't be hard coded beyond the minimum. The command class allows for a short cut key to be associated and that should provide the nescessary access. Overriding the keybouard handler is really too low level for what is already provided by the framework.


                                  Panic, Chaos, Destruction. My work here is done.

                                  A Offline
                                  A Offline
                                  Abhijit Jana
                                  wrote on last edited by
                                  #20

                                  That's true. Thanks !

                                  Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups