WM 2005/ CF 2.0 - This.Hide not working?

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

In the form_load event of form, i have code that hides the form:
this.hide().

This code worked fine under WM2003, but does not work in WM2005. Is
this a bug or degin/feature?
 
Shouldn't be a problem, but why not set the Form's visible property to false
in the constructor? That's where it should be done.

-Chris
 
Hmm...i have tried that as well (setting this.visible = false) in both
the form_load and the constructor, yet it is still being shown. odd
 
OK,

I started with a brand new project and the only class (besides
Program.cs) 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 = true;
}

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

I started with a brand new project and the only class (besides
Program.cs) 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 = true;
}

private void Form1_Load(object sender, EventArgs e)
{
//this.Hide();
this.Visible = true;
}
}
}
 
Sorry, "this.Visible = true" should read "this.Visible=false". It
does not hide the form on startup
 
It seems that Load event fires too early. I suggest you use Activate
event for that and that use Timer to remove it completely (since title
bar still remains):

public Form1()
{
InitializeComponent();
Activated += new EventHandler(Form1_Activated);
}

void t_Tick(object sender, EventArgs e)
{
Hide();
t.Enabled = false;
}

Timer t = new Timer();
void Form1_Activated(object sender, EventArgs e)
{
//Hide();
Activated -= new EventHandler(Form1_Activated);

// preparing timer
t.Tick += new EventHandler(t_Tick);
t.Interval = 100;
t.Enabled = true;
}
 
Back
Top