This topic has not yet been rated - Rate this topic

ToolStripItem.Visible Property

Gets or sets a value indicating whether the item is displayed.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public bool Visible { get; set; }

Property Value

Type: System.Boolean
true if the item is displayed; otherwise, false.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
There should be a reference to the 'Available' property
The Visible property is closely related to the Available property.

Getting the Visible property gives you the actual state of the object, i.e. if you can see it on the screen, it returns Visible = true , and getting the Available property is more what we would expect from the previous behaviour, which is roughly the answer to the question: 'will it become visible if I click on its parent'
After setting, Visible state cannot be read back immediately

Note that if you set item.Visible, you will not be able to see the change in your debugger, or read it back from your code immediately.

i.e. The first example below will exhibit unexpected behaviour, while the second one works:

item.Visible = DecideIfItemIsVisible();
if (item.Visible)
  ...



bool isVisible = DecideIfItemIsVisible();
item.Visible = isVisible;
if (isVisible)
  ...