I have the following code :
This call the second form
private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
Update fm = new Update();
fm.ShowDialog();
}
This is the constructor
public Update()
{
InitializeComponent();
}
This is the load
private void Update_Load(object sender, EventArgs e)
{
String ver = checkver();
if (ver == "update")
{
if (RemoteFileExists(dlUrl) == true)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri(dlUrl), "");
}
else
MessageBox.Show("An error occurred. Please try later.");
}
else if (ver == "newest")
{
MessageBox.Show("You are currently using the newest version.");
this.Close();
}
else
{
this.Close();
}
}
My problem is, that when the function result is 2 or 3 the form show up for millisecond and then close (flashing). I want the form to not flash. Is it possible?
I tried to use this.Hide(), this.Visible = False but nothing helped.
EDIT: I put the original code EDIT2: Put more code
You can hide the form before loading and then set it back to visible in your
if else
conditions. e.g:And then:
You should probably do whatever check you're performing before you choose to open the form in the first place.
So something like:
Maybe hide it first, then only show it if funct() == "1":
try this
The best way to do so :
I assume
Update_Load
is yourFormLoad
Handler? That is called after your form has been displayed. If you don't want to display it, that's too late. Change yourupdateToolStripMenuItem_Click
to this:And change your
Update_Load
to: