This documentation is archived and is not being maintained.

TreeNode.IsVisible Property

Gets a value indicating whether the tree node is visible.

[Visual Basic]
Public ReadOnly Property IsVisible As Boolean
[C#]
public bool IsVisible {get;}
[C++]
public: __property bool get_IsVisible();
[JScript]
public function get IsVisible() : Boolean;

Property Value

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

Example

[Visual Basic, C#, C++] The following 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 assumes you have a TreeView control on a Form that contains a collection of TreeNode object, and a Button. There should be enough tree nodes so they are not all visible in the tree view control.

[Visual Basic] 
Private Sub button3_Click(sender As Object, _
  e As System.EventArgs) Handles button3.Click
   Dim lastNode as TreeNode
   lastNode = treeView1.Nodes(treeView1.Nodes.Count - 1). _
     Nodes(treeView1.Nodes(treeView1.Nodes.Count - 1).Nodes.Count - 1)

   If Not lastNode.IsVisible Then
      lastNode.EnsureVisible()
      MessageBox.Show(lastNode.Text & _
        " tree node is visible.")
   End If
End Sub

[C#] 
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.");
   }
}

[C++] 
private:
    void button3_Click(Object* /*sender*/, System::EventArgs* /*e*/) {
        TreeNode* lastNode = 
            treeView1->Nodes->Item[treeView1->Nodes->Count - 1]->
            Nodes->Item[treeView1->Nodes->Item[treeView1->Nodes->
            Count - 1]->Nodes->Count - 1];

        if (!lastNode->IsVisible) {
            lastNode->EnsureVisible();
            MessageBox::Show(String::Concat(lastNode->Text, 
                S" tree node is visible."));
        }
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

TreeNode Class | TreeNode Members | System.Windows.Forms Namespace | NextVisibleNode | PrevVisibleNode

Show: