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. How to Close a Form when openning?

How to Close a Form when openning?

Scheduled Pinned Locked Moved C#
tutorialquestion
7 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.
  • K Offline
    K Offline
    Khoa Bui
    wrote on last edited by
    #1

    Let see this case: I need to show the aform, and write code aform f = new aform(someparameter); f.Show(); and in the form's code. I use "someparameter" to determine if I should still show the form or Close it. (this is done automatically, in FormLoad, constructor... etc; without anymore interaction from user (like event)) How this can be done?

    C 1 Reply Last reply
    0
    • K Khoa Bui

      Let see this case: I need to show the aform, and write code aform f = new aform(someparameter); f.Show(); and in the form's code. I use "someparameter" to determine if I should still show the form or Close it. (this is done automatically, in FormLoad, constructor... etc; without anymore interaction from user (like event)) How this can be done?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      this.Close(); It's the wrong model though - you should work out if you want to show it before you do. Anyone looking at this code is right to assume the form will be shown. Christian Graus - Microsoft MVP - C++

      C 1 Reply Last reply
      0
      • C Christian Graus

        this.Close(); It's the wrong model though - you should work out if you want to show it before you do. Anyone looking at this code is right to assume the form will be shown. Christian Graus - Microsoft MVP - C++

        C Offline
        C Offline
        codeprojectin
        wrote on last edited by
        #3

        If at all, you want to do - Override the constructor with parameters public Form3(string args) { if args=="dontshow!" this.Close() // and dispose the object and come out } However, the best and easier way to handle is to do it before hand since you have the parameters in hand before!

        C 1 Reply Last reply
        0
        • C codeprojectin

          If at all, you want to do - Override the constructor with parameters public Form3(string args) { if args=="dontshow!" this.Close() // and dispose the object and come out } However, the best and easier way to handle is to do it before hand since you have the parameters in hand before!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Why do people keep answering questions by posting under someone elses answer ? Christian Graus - Microsoft MVP - C++

          W C 2 Replies Last reply
          0
          • C Christian Graus

            Why do people keep answering questions by posting under someone elses answer ? Christian Graus - Microsoft MVP - C++

            W Offline
            W Offline
            Weiye Chen
            wrote on last edited by
            #5

            Christian Graus wrote: Why do people keep answering questions by posting under someone elses answer ? :laugh: I don't know why, but apparently you seems to be getting a couple of them. Weiye Chen Life is hard, yet we are made of flesh...

            1 Reply Last reply
            0
            • C Christian Graus

              Why do people keep answering questions by posting under someone elses answer ? Christian Graus - Microsoft MVP - C++

              C Offline
              C Offline
              codeprojectin
              wrote on last edited by
              #6

              Thats because we had answered at the same time! believe from various locations. Take care, sorry for the trouble guys for this thread!

              D 1 Reply Last reply
              0
              • C codeprojectin

                Thats because we had answered at the same time! believe from various locations. Take care, sorry for the trouble guys for this thread!

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                No, it's not. You clicked on Reply while looking at Christian's answer! Your post is 20 minutes later this his. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                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