This documentation is archived and is not being maintained.

TreeNode.IsVisible Property

Gets a value indicating whether the tree node is visible or partially visible.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public bool IsVisible { get; }
/** @property */
public boolean get_IsVisible ()

public function get IsVisible () : boolean

Not applicable.

Property Value

true if the tree node is visible or partially visible; otherwise, false.

The following code example brings the last child tree node of the last root tree node into view in the tree view when a button is clicked. This example requires that you have a TreeView control on a Form that contains a collection of TreeNode objects, and a Button. There should be enough tree nodes so they are not all visible in the tree view control.

private void button3_Click(object sender, System.EventArgs e)
{
   TreeNode lastNode = treeView1.Nodes[treeView1.Nodes.Count - 1].
     Nodes[treeView1.Nodes[treeView1.Nodes.Count - 1].Nodes.Count - 1];

   if (!lastNode.IsVisible)
   {
      lastNode.EnsureVisible();
      MessageBox.Show(lastNode.Text + " tree node is visible.");
   }
}

private void button3_Click(Object sender, System.EventArgs e)
{
    TreeNode lastNode = treeView1.get_Nodes().get_Item(
        (treeView1.get_Nodes().get_Count() - 1)).get_Nodes().
        get_Item((treeView1.get_Nodes().get_Item(treeView1.get_Nodes().
        get_Count() - 1).get_Nodes().get_Count() - 1));

    if (!(lastNode.get_IsVisible())) {
        lastNode.EnsureVisible();
        MessageBox.Show(lastNode.get_Text() + " tree node is visible.");
    }
} //button3_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: