-3

I know this question seems very simple but its not working for me, i think i changed a property by accident so the form wont go invisible.

on load, i have :

this.Visible = false;
this.ShowInTaskbar = false;
this.ShowIcon = false;

it doesnt show in taskbar or the icon but for some reason its still visible like in the image below

enter image description here

i know thats the form because i changed the color to red and it turned red

Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
Jason
  • 233
  • 4
  • 17

2 Answers2

3

This is what you can do:

private void Form1_Load(object sender, EventArgs e)
{
    this.Opacity = 0; //Add this line.
    this.Visible = false;
    this.ShowInTaskbar = false;
    this.ShowIcon = false;
}
Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
  • 1
    that worked, im still curious as to what i did that was making it show as this.visible should of worked – Jason Jul 06 '16 at 18:50
  • 1
    Visible won't do anything in the Loaded event. – Kinetic Jul 06 '16 at 18:50
  • 1
    This answer will make the form invisible rather than hidden. If that's what you wanted, it's a nice answer. – Kinetic Jul 06 '16 at 18:51
  • @Will easy, `Load` event will get called when the form is shown (and it'll be shown only -after- executing the `Load` event handlers). Personally, I prefer minimizing the window (and not show in taskbar) or just don't `Show` it for a start, rather than set the opacity at 0, but your choice. – Jcl Jul 06 '16 at 18:51
  • @KiNeTiC the OP wants the Form to be Invisible :) – Raktim Biswas Jul 06 '16 at 18:52
  • Your code make the form transparent, but it will still be visible (the Visible property will be true). – Kinetic Jul 06 '16 at 18:54
  • @KiNeTiC sure...I'll better remove that comment and set the visibility to false `this.Visible = false;` :) – Raktim Biswas Jul 06 '16 at 18:56
2

If you're trying to hide the form, you can use :

this.Hide();
Kinetic
  • 2,640
  • 17
  • 35