TreeNode.IsVisible 屬性

定義

取得值,指出是否可看見整個或部分樹狀節點。Gets a value indicating whether the tree node is visible or partially visible.

public:
 property bool IsVisible { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsVisible { get; }
member this.IsVisible : bool
Public ReadOnly Property IsVisible As Boolean

屬性值

如果可看見整個或部分樹狀節點,則為 true,否則為 falsetrue if the tree node is visible or partially visible; otherwise, false.

屬性

範例

下列程式碼範例會在按一下按鈕時,將最後一個根樹狀節點的最後一個子樹狀節點,帶入樹狀檢視中的 view。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. TreeView這個範例要求您Form在上有一個控制項, TreeNode其中包含物件的集合和ButtonThis 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 that they are not all visible in the tree view control.

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( String::Concat( lastNode->Text, " tree node is visible." ) );
   }
}
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 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

適用於

另請參閱