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