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?
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?
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
Declare a Boolean static field.
public class Form1 : ....
{
static bool flag=true;
void form1_load(...) {
if(flag) {
....
flag=false;
}
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.