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. Escape key control in c#

Escape key control in c#

Scheduled Pinned Locked Moved C#
questioncsharp
4 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.
  • K Offline
    K Offline
    Krishna Varadharajan
    wrote on last edited by
    #1

    Hi, In my windows application pop up windows need to be get closed by pressing Esc key. How can i achieve this.....??? Thanks.

    krishna

    OriginalGriffO A 2 Replies Last reply
    0
    • K Krishna Varadharajan

      Hi, In my windows application pop up windows need to be get closed by pressing Esc key. How can i achieve this.....??? Thanks.

      krishna

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Give the form a button (normally labelled "Cancel") with the DialogResult property set to Cancel. Set the forms CancelButton property to this button. It'll do the rest.

      Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • K Krishna Varadharajan

        Hi, In my windows application pop up windows need to be get closed by pressing Esc key. How can i achieve this.....??? Thanks.

        krishna

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        On the form's key down event, try using this code or something sinilar.

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
        if (e.KeyCode == Keys.Escape)
        this.Hide();
        }

        The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files. Visit the Hindi forum here.

        K 1 Reply Last reply
        0
        • A Abhinav S

          On the form's key down event, try using this code or something sinilar.

          private void Form1_KeyDown(object sender, KeyEventArgs e)
          {
          if (e.KeyCode == Keys.Escape)
          this.Hide();
          }

          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files. Visit the Hindi forum here.

          K Offline
          K Offline
          Krishna Varadharajan
          wrote on last edited by
          #4

          Thanks for you info....

          krishna

          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