|
-
Mar 10th, 2006, 06:48 AM
#1
Thread Starter
Hyperactive Member
Windows Forms Really stupid Q. Visible Property?
Why can't I set my form invisible in the Form Load event ?
Sorry to be abrupt but I'm stumped as to why this property doesnt work ?
Cheers.
Chubby.
-
Mar 10th, 2006, 07:36 AM
#2
Re: Windows Forms Really stupid Q. Visible Property?
It does work but the form gets drawn on form_Paint which comes after form_load you can see this for yourself by doing the following and you'll notice that the form isn't displayed for 15 seconds
Code:
private void Form1_Load(object sender, System.EventArgs e)
{
Thread.Sleep(15000);
}
So if you needed to you could set the form.visible = false; in form_paint.
Last edited by Fishcake; Mar 10th, 2006 at 07:40 AM.
-
Mar 10th, 2006, 09:00 AM
#3
Thread Starter
Hyperactive Member
Re: Windows Forms Really stupid Q. Visible Property?
 Originally Posted by Fishcake
It does work but the form gets drawn on form_Paint which comes after form_load you can see this for yourself by doing the following and you'll notice that the form isn't displayed for 15 seconds
Code:
private void Form1_Load(object sender, System.EventArgs e)
{
Thread.Sleep(15000);
}
So if you needed to you could set the form.visible = false; in form_paint.
Thanks
I went round the houses with this (and probably this is the right way to do it (not saying your way is wrong, just for what I need I really should use a static void Main() in a separate class),
the .Net example: ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskSettingFormToBeInvisibleAtItsInception.htm
explains the lifetime of the form etc but in basic terms, add a new Class to the NameSpace containing the instance of the form, then add a static void Main() (remembering to declare the instance of your form outside of this (again, static) and put similar code to thefollowing in the Main (ensure the startup object of the project points to the new Main())
Code:
public class MainApp
{
public static frmPop f;
public static void Main()
{
f = new frmPop();
f.Visible = false;
Application.Run(f);
}
}
Thanks for the help, would have been eaiser with the Paint I'm sure !
Cheers.
Chubby.
-
Mar 10th, 2006, 10:17 AM
#4
Re: Windows Forms Really stupid Q. Visible Property?
The way you've posted is how i would open form on application start. Sorry wasn't clear what you wanted from your first post. I was wondering what you were going to do with your invisible form after you'd opened it.
-
Mar 10th, 2006, 10:58 AM
#5
Thread Starter
Hyperactive Member
Re: Windows Forms Really stupid Q. Visible Property?
 Originally Posted by Fishcake
The way you've posted is how i would open form on application start. Sorry wasn't clear what you wanted from your first post. I was wondering what you were going to do with your invisible form after you'd opened it.
sorry for the confusion, I (as you can more likely gather) am new to c#... (and .Net in general) and still basing my theories out of the old VB...
Just expected to be able to set the Form non-visual with a property, and when unable to do that, the natural progression was to set it on inception using code, and when that didn't work....
Thanks
Chubby..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|