0

Ok, I have a code that I only want to use for the first form1 load, so that means never use it agian.

So how do I use a code once then never use it again?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
0

Do you mean never use it again while the application is running? Or never use it when the application is run in the future?

If it is the latter, you could add a bool flag to your projects Properties Settings.settings which is initialised to false. Upon entering form1_Load for the first time, the flag would be checked to ensure it is false, allowing the code to execute. The flag is then updated inhibiting it from the code being executed in the future.

Cameron

0

Declare a Boolean static field.

public class Form1 : ....
 {
    static bool flag=true;

    void form1_load(...) {
           if(flag) {
                  ....
                  flag=false;
           }
    }
 }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.