Results 1 to 5 of 5

Thread: Windows Forms Really stupid Q. Visible Property?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    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.

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: Windows Forms Really stupid Q. Visible Property?

    Quote 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.

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: Windows Forms Really stupid Q. Visible Property?

    Quote 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
  •  



Click Here to Expand Forum to Full Width