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. I don't have topic for this

I don't have topic for this

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.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    I want to do some operation when the application run,but after my form become visible,If I put my operation in construtor or Load ,it does the operation before the form become visible. Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

    R 1 Reply Last reply
    0
    • M Mazdak

      I want to do some operation when the application run,but after my form become visible,If I put my operation in construtor or Load ,it does the operation before the form become visible. Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

      R Offline
      R Offline
      Rupel
      wrote on last edited by
      #2

      maybe something like

      class Form1 : System.Windows.Forms.Form
      {

      bool shown = false;

      ...

      private void Form1_Activated(object sender, System.EventArgs e)
      {
      if (!shown)
      {
      shown = true;
      MessageBox.Show("I'm here.");
      }
      }
      }

      does the job for you. the "Activated" event with a bool to show it only once (after construction) not really nice, because everytime the form is activated this comparison takes place, but hey: in times of gigahertz and garbage-collectors - who cares about one function call and one comparison ;) :wq

      M J 2 Replies Last reply
      0
      • R Rupel

        maybe something like

        class Form1 : System.Windows.Forms.Form
        {

        bool shown = false;

        ...

        private void Form1_Activated(object sender, System.EventArgs e)
        {
        if (!shown)
        {
        shown = true;
        MessageBox.Show("I'm here.");
        }
        }
        }

        does the job for you. the "Activated" event with a bool to show it only once (after construction) not really nice, because everytime the form is activated this comparison takes place, but hey: in times of gigahertz and garbage-collectors - who cares about one function call and one comparison ;) :wq

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Thank you,I'll check it as soos as I go home. :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

        1 Reply Last reply
        0
        • R Rupel

          maybe something like

          class Form1 : System.Windows.Forms.Form
          {

          bool shown = false;

          ...

          private void Form1_Activated(object sender, System.EventArgs e)
          {
          if (!shown)
          {
          shown = true;
          MessageBox.Show("I'm here.");
          }
          }
          }

          does the job for you. the "Activated" event with a bool to show it only once (after construction) not really nice, because everytime the form is activated this comparison takes place, but hey: in times of gigahertz and garbage-collectors - who cares about one function call and one comparison ;) :wq

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          Actually there is an even better way if you are really concerned about performance.

          class Form1 : System.Windows.Forms.Form
          {
          public Form1()
          {
          InitializeComponent();

          this.Activated += new EventHandler(Activated\_PerformOnce);
          

          }

          private void Activated_PerformOnce(object sender, System.EventArgs e)
          {
          this.Activated -= new EventHandler(Activated_PerformOnce);

          // Do your on form show stuff
          

          }
          }

          Amazing what comes to you while you sleep :-P James Simplicity Rules!

          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