this.hide or this.visible=true not working...

Hi,

i have a form consisting of only a text box. in the form_load, i have code that reads "this.hide()". However then the form loads, it is still visible. I have also tried "this.visible = true" and have tried them in the forms constructor as well, but nothing i try seems to work.

Is anyone else having this issue with WM 2005 and CF 2.0




Answer this question

this.hide or this.visible=true not working...

  • Sarah Camsell

    Ilya,

    although this works to hide the form, the Form name and the form's top right "OK" button still show in the top Task bar. I have tried SendToBack and TopMost = false to resolve this, but to no avail. Any ideas



  • Bilgehan

    It's like this by design.

    The Application.Run (myForm) method does a Visible = true before entering the message loop.

    During the "Visible=true" management (but before actually setting it) it calls the Load event of your form.

    The order is:

    1 Form constructor

    2 Load event

    3 Visible = true

    I found no way to solve this problem apart setting a short Timer

    If you are curious, just set a breakpoint inside your Load event and take

    a look at the call stack


  • Adatacorp

    Hi,

    I had also faced this issue, my workaround was to call Hide() in the tick of a timer with interval set to 10ms.

    didn't figured out why ... (maybe something with that the event raised before it really activated.. or maybe someone will give me a better answer.. :P)

    cheers,

    Oren.


  • Demann

    Please try hiding it from Activated event:

    private void Form1_Activated(object sender, EventArgs e)

    {

    this.Hide();

    }



  • Chyi Pin

    Thanks much Ilya, that worked. Interesting feature



  • myrdhrin

    Still hoping a microsoft technical engineer will provide an answer to this issue.

    thakn you.



  • Hoots

    try doing a me.update after you have hidden the form.

  • niketu

    doesn't work. i'm amazed that simple things like this are so difficult.

  • Ron A. Buckton

    that worked...but seems like a bug to me. I wonder if it will be acknowledged as such and fixed.



  • SashaJuric

    OK,

    I started with a brand new project and the only code in that project is below.  The form refuses to be hidden...is this a bug

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace test
    {
         
    public partial class Form1 : Form
         
    {
               
    public Form1()
                {
                         InitializeComponent();
                        
    //this.Hide();
                        
    this.Visible = false;
                }

                private void Form1_Load(object sender, EventArgs e)
               
    {
                       
    //this.Hide();
                       
    this.Visible = false;
                
    }
         
    }
    }



  • this.hide or this.visible=true not working...