次の方法で共有


TreeNode.IsVisible プロパティ

ツリー ノードが表示されているかどうかを示す値を取得します。

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

プロパティ値

ツリー ノードが表示されている場合は true 。それ以外の場合は false

使用例

[Visual Basic, C#, C++] ボタンがクリックされたときに、最後のルート ツリー ノードの最後の子ツリー ノードをツリー ビューの表示領域内に表示させる例を次に示します。この例は、 TreeNode オブジェクトのコレクション、および Button を格納する TreeView コントロールが、 Form に配置されていることを前提にしています。十分な数のツリー ノードを作成し、一部のノードがツリー ビュー コントロールの表示領域に収まらないようにします。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

TreeNode クラス | TreeNode メンバ | System.Windows.Forms 名前空間 | NextVisibleNode | PrevVisibleNode