すべてのツリー ノードを展開します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Sub ExpandAll
'使用
Dim instance As TreeView
instance.ExpandAll
public void ExpandAll ()
public:
void ExpandAll ()
public void ExpandAll ()
public function ExpandAll ()
解説
ExpandAll メソッドは、TreeView コントロール内の、子ツリー ノードを含むすべての TreeNode オブジェクトを展開します。
注意
TreeNode の状態は永続的です。たとえば、ExpandAll メソッドを呼び出してから、それぞれのルート ツリー ノードを折りたたむとします。子ツリー ノードは折りたたまれていないため、ルート ツリー ノードを再度展開したときに、これらの子ツリー ノードは以前展開されたときの状態で表示されます。CollapseAll メソッドを呼び出すと、確実にすべてのツリー ノードを折りたたんだ状態で表示できます。
使用例
Checkbox がオンになったとき TreeView コントロールのツリー ノードをすべて展開し、Checkbox がオフになったときに FirstNode を折りたたむコード例を次に示します。この例は、Form 上に、Checkbox と TreeView コントロール が配置され、その TreeView に、複数の TreeNode オブジェクト (3 レベル以上を推奨) を持つ TreeNodeCollection が設定されていることを前提にしています。
Private Sub myCheckBox_CheckedChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles myCheckBox.CheckedChanged
' If the check box is checked, expand all the tree nodes.
If myCheckBox.Checked = True Then
myTreeView.ExpandAll()
Else
' If the check box is not cheked, collapse the first tree node.
myTreeView.Nodes(0).FirstNode.Collapse()
MessageBox.Show("The first and last node of CutomerList root node is collapsed")
End If
End Sub
private void myCheckBox_CheckedChanged(object sender, System.EventArgs e)
{
// If the check box is checked, expand all the tree nodes.
if (myCheckBox.Checked == true)
{
myTreeView.ExpandAll();
}
else
{
// If the check box is not cheked, collapse the first tree node.
myTreeView.Nodes[0].FirstNode.Collapse();
MessageBox.Show("The first and last node of CutomerList root node is collapsed");
}
}
void myCheckBox_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// If the check box is checked, expand all the tree nodes.
if ( myCheckBox->Checked == true )
{
myTreeView->ExpandAll();
}
else
{
// If the check box is not cheked, collapse the first tree node.
myTreeView->Nodes[ 0 ]->FirstNode->Collapse();
MessageBox::Show( "The first and last node of CutomerList root node is collapsed" );
}
}
private void myCheckBox_CheckedChanged(Object sender, System.EventArgs e)
{
// If the check box is checked, expand all the tree nodes.
if (myCheckBox.get_Checked() == true) {
myTreeView.ExpandAll();
}
else {
// If the check box is not cheked, collapse the first tree node.
myTreeView.get_Nodes().get_Item(0).get_FirstNode().Collapse();
MessageBox.Show("The first and last node of CutomerList root "
+ "node is collapsed");
}
} //myCheckBox_CheckedChanged
プラットフォーム
Windows 98, Windows 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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0
参照
関連項目
TreeView クラス
TreeView メンバ
System.Windows.Forms 名前空間
Expand
CollapseAll