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. Hiding Form on Startup

Hiding Form on Startup

Scheduled Pinned Locked Moved C#
question
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.
  • A Offline
    A Offline
    Adam Durity
    wrote on last edited by
    #1

    Hey, How do you hide a form on startup so that it doesn't show at all. I want to hide a form initially until the user clicks on a notifyIcon. Currently...

    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent();
    this.Hide(); //or this.Visible = false;
    }

    ...does not work. Any suggestions? -- Adam "If you can't beat your computer in chess, try kickboxing"

    J I A 3 Replies Last reply
    0
    • A Adam Durity

      Hey, How do you hide a form on startup so that it doesn't show at all. I want to hide a form initially until the user clicks on a notifyIcon. Currently...

      public Form1()
      {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();
      this.Hide(); //or this.Visible = false;
      }

      ...does not work. Any suggestions? -- Adam "If you can't beat your computer in chess, try kickboxing"

      J Offline
      J Offline
      JM_FL
      wrote on last edited by
      #2

      Hey Adam, try this, to prevent the form to be created at startup, if the no-button is clicked. if (MessageBox.Show("Start Application", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Application.Run(new Form1()); } Maybe it's helpful... Jörg

      1 Reply Last reply
      0
      • A Adam Durity

        Hey, How do you hide a form on startup so that it doesn't show at all. I want to hide a form initially until the user clicks on a notifyIcon. Currently...

        public Form1()
        {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        this.Hide(); //or this.Visible = false;
        }

        ...does not work. Any suggestions? -- Adam "If you can't beat your computer in chess, try kickboxing"

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        why not set a madule main function to be startup rather than a form. then you can do what you want with it I'm not an expert yet, but I play one at work. Yeah and here too.

        1 Reply Last reply
        0
        • A Adam Durity

          Hey, How do you hide a form on startup so that it doesn't show at all. I want to hide a form initially until the user clicks on a notifyIcon. Currently...

          public Form1()
          {
          //
          // Required for Windows Form Designer support
          //
          InitializeComponent();
          this.Hide(); //or this.Visible = false;
          }

          ...does not work. Any suggestions? -- Adam "If you can't beat your computer in chess, try kickboxing"

          A Offline
          A Offline
          Adam Durity
          wrote on last edited by
          #4

          Okay, I've got a semi working solution, tell me if i'm doing anything that could lead to problems later.

          public class Class1
          {
          static void Main()
          {
          Form1 form = new Form1();
          Application.Run();
          }
          }
           
          public class Form1 : System.Windows.Form
          {
          public Form1()
          {
          IntiallizeComponent();
          this.Visible = false;
          }
          }

          This creates the notifyIcon in the system tray, but does not show the form. When the notifyIcon is double clicked, then the form pops up. When the form is disposed, i have it call Application.Exit() so that the Application quits properly...this is mostly what i'm concerned about, that the tread is terminating properly. -- Adam "If you can't beat your computer in chess, try kickboxing"

          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