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. close a window on btn clk [modified]

close a window on btn clk [modified]

Scheduled Pinned Locked Moved C#
questioncsharptutorial
12 Posts 7 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 Offline
    A Offline
    aeman
    wrote on last edited by
    #1

    hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

    modified on Tuesday, March 1, 2011 1:56 AM

    OriginalGriffO J H A 5 Replies Last reply
    0
    • A aeman

      hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

      modified on Tuesday, March 1, 2011 1:56 AM

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

      this.Close will close the current Form instance: If this is the main form that was opened when you application started, it will indeed close the application. For other forms it will just close them. If you need to alter this behaviour, you need to look in "program.cs" at the Main method: the Application.Run(); line starts your form going, and waits until it closes. Be careful to provide some mechanism for closing your application or you will just annoy your users!

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

      "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
      • A aeman

        hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

        modified on Tuesday, March 1, 2011 1:56 AM

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

        Who have you annoyed? I don't know who down voted a reasonable question, but I have compensated.

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

        "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

        R M 2 Replies Last reply
        0
        • OriginalGriffO OriginalGriff

          Who have you annoyed? I don't know who down voted a reasonable question, but I have compensated.

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

          R Offline
          R Offline
          RobCroll
          wrote on last edited by
          #4

          It would be some loser who doesn't understand that not everyone in the world speaks English. Imagine the shock when they go OS and discover the world is full of foreigners. :wtf: [edit] I take back that comment. It was given a 1 because it was txt [edit]

          "You get that on the big jobs."

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Who have you annoyed? I don't know who down voted a reasonable question, but I have compensated.

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            OriginalGriff wrote:

            Who have you annoyed

            Everyone who attempts to read the question. I realise english is unlikely to be the OPs first language but that is bloody difficult to read. A bit petty but you asked.

            Never underestimate the power of human stupidity RAH

            OriginalGriffO L 2 Replies Last reply
            0
            • A aeman

              hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

              modified on Tuesday, March 1, 2011 1:56 AM

              J Offline
              J Offline
              jasonmp
              wrote on last edited by
              #6

              If you want to "Close" the Form, then this.Close(); will work. However, if you want to simply hide it, then this.Hide(); will work, and to Dispose of the Window/Form, then use this.Dispose();

              1 Reply Last reply
              0
              • M Mycroft Holmes

                OriginalGriff wrote:

                Who have you annoyed

                Everyone who attempts to read the question. I realise english is unlikely to be the OPs first language but that is bloody difficult to read. A bit petty but you asked.

                Never underestimate the power of human stupidity RAH

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

                :laugh: I know what you mean! Still not a reason for downvoting it though: ignore it instead, or post "wftru n abt?"

                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                "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
                • M Mycroft Holmes

                  OriginalGriff wrote:

                  Who have you annoyed

                  Everyone who attempts to read the question. I realise english is unlikely to be the OPs first language but that is bloody difficult to read. A bit petty but you asked.

                  Never underestimate the power of human stupidity RAH

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

                  Mycroft Holmes wrote:

                  I realise english is unlikely to be the OPs first language but that is bloody difficult to read.

                  That's no reason to down vote them. I wonder how many English speakers here could formulate a clear question or answer in Arabic, Hindi, Greek or Russian for example.

                  I must get a clever new signature for 2011.

                  M 1 Reply Last reply
                  0
                  • L Lost User

                    Mycroft Holmes wrote:

                    I realise english is unlikely to be the OPs first language but that is bloody difficult to read.

                    That's no reason to down vote them. I wonder how many English speakers here could formulate a clear question or answer in Arabic, Hindi, Greek or Russian for example.

                    I must get a clever new signature for 2011.

                    M Offline
                    M Offline
                    Mycroft Holmes
                    wrote on last edited by
                    #9

                    Richard MacCutchan wrote:

                    That's no reason to down vote them

                    Oh I agree with you there, as I said, very petty. I once had to communcate with some Japanese devs, bloody impossible, my multi lingual skills are non existent.

                    Never underestimate the power of human stupidity RAH

                    1 Reply Last reply
                    0
                    • A aeman

                      hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

                      modified on Tuesday, March 1, 2011 1:56 AM

                      H Offline
                      H Offline
                      Hum Dum
                      wrote on last edited by
                      #10

                      aeman wrote:

                      window like my document on btn clk in c# but i dont klnw how to close this window.

                      If by this you mean open another program from c# like word the close it

                      Process []pArry = Process.GetProcesses();

                      foreach(Process p in pArry)
                      {
                      string s = p.ProcessName;
                      s = s.ToLower();
                      if (s.CompareTo("winword") ==0)
                      {
                      p.Kill();
                      }
                      }

                      Above code will close word application.

                      A 1 Reply Last reply
                      0
                      • A aeman

                        hi. i knw how to opn a window like my document on btn clk in c# but i dont knw how to close this window. if i use close() function thn it close the program. how can i clse the windo on btn clk?

                        modified on Tuesday, March 1, 2011 1:56 AM

                        A Offline
                        A Offline
                        aeman
                        wrote on last edited by
                        #11

                        sory i have some mistakes in my question. i have edited my question. i was in hury that day so couldnt notice.

                        1 Reply Last reply
                        0
                        • H Hum Dum

                          aeman wrote:

                          window like my document on btn clk in c# but i dont klnw how to close this window.

                          If by this you mean open another program from c# like word the close it

                          Process []pArry = Process.GetProcesses();

                          foreach(Process p in pArry)
                          {
                          string s = p.ProcessName;
                          s = s.ToLower();
                          if (s.CompareTo("winword") ==0)
                          {
                          p.Kill();
                          }
                          }

                          Above code will close word application.

                          A Offline
                          A Offline
                          aeman
                          wrote on last edited by
                          #12

                          i dont want to opn the another program but i want to close the windo that i opn on the btn clk. for example if i clk the btn 'MY document' opns now i want to close it not by clking the cross but cliking the btn on my form. hope question is clear.

                          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