TreeView.GetNodeCount メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TreeView.GetNodeCount メソッドの意味・解説 

TreeView.GetNodeCount メソッド

ツリー ノードの数を取得しますツリー ビュー コントロール割り当てられているすべてのサブツリー内のツリー ノードを数に含めることもできます

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function GetNodeCount ( _
    includeSubTrees As Boolean _
) As Integer
Dim instance As TreeView
Dim includeSubTrees As Boolean
Dim returnValue As Integer

returnValue = instance.GetNodeCount(includeSubTrees)
public int GetNodeCount (
    bool includeSubTrees
)
public:
int GetNodeCount (
    bool includeSubTrees
)
public int GetNodeCount (
    boolean includeSubTrees
)
public function GetNodeCount (
    includeSubTrees : boolean
) : int

パラメータ

includeSubTrees

サブツリー内の TreeNode 項目を数に含め場合trueそれ以外場合false

戻り値
ツリー ノードの数。ツリー ビュー コントロール割り当てられているすべてのサブツリー内のツリー ノード含めることもできます

解説解説

includeSubTreestrue場合結果の値はツリー構造全体すべてのツリー ノードの数になります

使用例使用例

TreeView の PathSeparator プロパティ設定し、SelectedNode の TreeNodeCollection に含まれている子ツリー ノードの数を表示するコード例次に示しますツリー ビュー コントロール内のすべてのツリー ノード対する子ツリー ノード割合表示されます。この例は、Form 上に、ButtonTreeView コントロール配置され、その TreeView に、複数TreeNode オブジェクト (3 レベル以上を推奨) を持つ TreeNodeCollection設定されていることを前提にしています。

Private Sub myButton_Click(ByVal
 sender As Object, _
  ByVal e As System.EventArgs) Handles
 myButton.Click
   ' Set the tre view's PathSeparator property.
   myTreeView.PathSeparator = "."

   ' Get the count of the child tree nodes contained in the SelectedNode.
   Dim myNodeCount As Integer
 = myTreeView.SelectedNode.GetNodeCount(True)
   Dim myChildPercentage As Decimal
 = CDec(myNodeCount) / _
      CDec(myTreeView.GetNodeCount(True)) * 100

   ' Display the tree node path and the number of child nodes it and
 the tree view have.
   MessageBox.Show(("The '" + myTreeView.SelectedNode.FullPath
 + "' node has " _
      + myNodeCount.ToString() + " child nodes." +
 Microsoft.VisualBasic.ControlChars.Lf _
      + "That is " + String.Format("{0:###.##}",
 myChildPercentage) _
      + "% of the total tree nodes in the tree view control."))
End Sub
private void myButton_Click(object sender,
 System.EventArgs e)
{
   // Set the tre view's PathSeparator property.
   myTreeView.PathSeparator = ".";

   // Get the count of the child tree nodes contained in the SelectedNode.
   int myNodeCount = myTreeView.SelectedNode.GetNodeCount(true);
   decimal myChildPercentage = ((decimal)myNodeCount/
     (decimal)myTreeView.GetNodeCount(true)) * 100;

   // Display the tree node path and the number of child nodes it and
 the tree view have.
   MessageBox.Show("The '" + myTreeView.SelectedNode.FullPath + "'
 node has " 
     + myNodeCount.ToString() + " child nodes.\nThat is " 
     + string.Format("{0:###.##}", myChildPercentage)
 
     + "% of the total tree nodes in the tree view control.");
}
void myButton_Click( Object^ /*sender*/, System::EventArgs^ /*e*/
 )
{
   
   // Set the tre view's PathSeparator property.
   myTreeView->PathSeparator = ".";
   
   // Get the count of the child tree nodes contained in the SelectedNode.
   int myNodeCount = myTreeView->SelectedNode->GetNodeCount(
 true );
   Decimal myChildPercentage = ((Decimal)myNodeCount / (Decimal)myTreeView->GetNodeCount(
 true )) * 100;
   
   // Display the tree node path and the number of child nodes it and
 the tree view have.
   MessageBox::Show( String::Concat( "The '", myTreeView->SelectedNode->FullPath,
 "' node has ", myNodeCount, " child nodes.\nThat is ", String::Format(
 "{0:###.##}", myChildPercentage ), "% of the total tree nodes in the tree view control." ) );
}
private void myButton_Click(Object sender,
 System.EventArgs e)
{
    // Set the tre view's PathSeparator property.
    myTreeView.set_PathSeparator(".");
    // Get the count of the child tree nodes contained in the SelectedNode.
    int myNodeCount = myTreeView.get_SelectedNode().GetNodeCount(true);
    System.Decimal myChildPercentage =
        Decimal.Multiply(Decimal.Divide(new Decimal(myNodeCount)
,
        new Decimal(myTreeView.GetNodeCount(true))),
 new Decimal(100));
    // Display the tree node path and the number of child nodes it and
 the
    // tree view have.
    MessageBox.Show("The '" + myTreeView.get_SelectedNode().get_FullPath()
        + "' node has " + ((Int32)myNodeCount).ToString()
        + " child nodes.\nThat is " + String.Format("{0:###.##}"
,
        myChildPercentage)
        + "% of the total tree nodes in the tree view control.");
} //myButton_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

TreeView.GetNodeCount メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TreeView.GetNodeCount メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS