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. Showing Form at Run

Showing Form at Run

Scheduled Pinned Locked Moved C#
helpvisual-studioquestion
3 Posts 2 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.
  • O Offline
    O Offline
    ormonds
    wrote on last edited by
    #1

    I have an application which starts with:

       public Form1()
        {
            InitializeComponent();
            form = this;
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            textBox2.Text = "Initialising.....";
            this.Show();
            Refresh();
    

    When I run it from within VS the form appears as expected. When I publish the app, install it and then run I never see the form. Changing this.Show() to Form1.Show() gives error CS0120. Can anyone help?

    D 1 Reply Last reply
    0
    • O ormonds

      I have an application which starts with:

         public Form1()
          {
              InitializeComponent();
              form = this;
          }
      
          private void Form1\_Load(object sender, EventArgs e)
          {
              textBox2.Text = "Initialising.....";
              this.Show();
              Refresh();
      

      When I run it from within VS the form appears as expected. When I publish the app, install it and then run I never see the form. Changing this.Show() to Form1.Show() gives error CS0120. Can anyone help?

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

      Why on earth are you doing a Show and a Refresh in Form_Load? The form is drawn for the first time AFTER your Form_Load event handler returns. There's nothing to show yet and there's nothing to refresh! Remove those two lines of code:

      private void Form1_Load(object sender, EventArgs e)
      {
      textBox2.Text = "Initialising.....";
      }

      You also spelled "Initializing" wrong.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      O 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Why on earth are you doing a Show and a Refresh in Form_Load? The form is drawn for the first time AFTER your Form_Load event handler returns. There's nothing to show yet and there's nothing to refresh! Remove those two lines of code:

        private void Form1_Load(object sender, EventArgs e)
        {
        textBox2.Text = "Initialising.....";
        }

        You also spelled "Initializing" wrong.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        O Offline
        O Offline
        ormonds
        wrote on last edited by
        #3

        Thanks. I must be British: [https://writingexplained.org/recognise-or-recognize-difference\](https://writingexplained.org/recognise-or-recognize-difference)

        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