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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. using Same Shortcut keys on Different Tabs of a form

using Same Shortcut keys on Different Tabs of a form

Scheduled Pinned Locked Moved C#
csharphelpquestion
3 Posts 3 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.
  • W Offline
    W Offline
    Why so Serious
    wrote on last edited by
    #1

    Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..

    L L 2 Replies Last reply
    0
    • W Why so Serious

      Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..

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

      Set the Form's KeyPreview property to true and handle the KeyDown/KeyPress events. Don't handle the KeyDown/KeyPress events of the tab or the constituent controls. Within the event handler, you can look for specific key combinations and take action based on the active tab.

      1 Reply Last reply
      0
      • W Why so Serious

        Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..

        L Offline
        L Offline
        Liam Cairns Kelly
        wrote on last edited by
        #3

        I'd recommend a simple if or case statement (whichever you prefer) to identify the current selected tab.

        switch (tabControl.SelectedIndex)
        {
        case 0:
        //do stuff
        break;
        case 1:
        //do some other stuff
        break;
        }

        This would work under the assumption that you were using the tab indices to find out what's currently selected. There's also a function that allows you to check the current tab by its name. It'd work in the same respect as the .SelectedIndex function, expect you'd be using the tab names rather than the indices. It's the .SelectedTab function. I hope this was of some help. Happy programming! :)

        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