Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-make-your-control-invisible-at-run-time.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.1 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Make Your Control Invisible at Run Time 03/30/2017
csharp
vb
controls [Windows Forms], making invisible at run time
invisible controls
user controls [Windows Forms], invisible
custom controls [Windows Forms], invisible
run time [Windows Forms], making controls invisible
69eb2e72-32f5-4f79-a157-c2c5f60c1628

How to: Make Your Control Invisible at Run Time

There are times when you might want to create a user control that is invisible at run time. For example, a control that is an alarm clock might be invisible except when the alarm was sounding. This is easily accomplished by setting the xref:System.Windows.Forms.Control.Visible%2A property. If the xref:System.Windows.Forms.Control.Visible%2A property is true, your control will appear as normal. If false, your control will be hidden. Although code in your control may still run while invisible, you will not be able to interact with the control through the user interface. If you want to create an invisible control that still responds to user input (for example, mouse clicks), you should create a transparent control. For more information, see Giving Your Control a Transparent Background.

To make your control invisible at run time

  1. Set the xref:System.Windows.Forms.Control.Visible%2A property to false.

    ' To set the Visible property from within your object's own code.  
    Me.Visible = False  
    ' To set the Visible property from another object.  
    myControl1.Visible = False  
    
    // To set the Visible property from within your object's own code.  
    this.Visible = false;  
    // To set the Visible property from another object.  
    myControl1.Visible = false;  
    

See also