TreeView.ShowCheckBoxes プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TreeView.ShowCheckBoxes プロパティの意味・解説 

TreeView.ShowCheckBoxes プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

TreeView コントロールチェック ボックス表示されるノード種類を示す値を取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Property ShowCheckBoxes As
 TreeNodeTypes
Dim instance As TreeView
Dim value As TreeNodeTypes

value = instance.ShowCheckBoxes

instance.ShowCheckBoxes = value
public TreeNodeTypes ShowCheckBoxes { get;
 set; }
public:
property TreeNodeTypes ShowCheckBoxes {
    TreeNodeTypes get ();
    void set (TreeNodeTypes value);
}
/** @property */
public TreeNodeTypes get_ShowCheckBoxes ()

/** @property */
public void set_ShowCheckBoxes (TreeNodeTypes
 value)
public function get ShowCheckBoxes
 () : TreeNodeTypes

public function set ShowCheckBoxes
 (value : TreeNodeTypes)

プロパティ
TreeNodeTypes 値のビットごとの組み合わせ既定値TreeNodeType.None です。

例外例外
例外種類条件

ArgumentOutOfRangeException

ビットごとの組み合わせの値が、TreeNodeTypes 列挙体の範囲外あります

解説解説

TreeView コントロールでマルチノードの選択サポートするために、ノードイメージの横にチェック ボックス表示できますShowCheckBoxes プロパティ使用してチェック ボックス表示されるノード種類指定します。たとえば、このプロパティTreeNodeType.Parent設定されている場合ツリー内の親ノードに対してチェック ボックス表示されます。このプロパティ有効な値の一覧を次の表に示します

ShowCheckBoxes プロパティ使用される列挙型フラグ列挙体なので、ビットごとの演算によって複数の値を結合できます。たとえば、親ノードおよび葉ノードチェック ボックス表示するには、ビットごとの OR 演算子を使用してTreeNodeType.Parent 値と TreeNodeType.Leaf 値を結合します

チェック ボックス選択されているノード確認するには、CheckedNodes コレクションノード反復処理ます。

単一選択のみをサポートする必要がある場合は、SelectedNode プロパティ使用検討してください

このプロパティの値はビューステート格納されます。

使用例使用例

ShowCheckBoxes プロパティ使用して異なノード種類チェック ボックス表示または非表示にするコード例次に示します

<%@ Page Language="VB" %>

<script runat="server">

  Sub Button_Click(ByVal sender As
 Object, ByVal e As EventArgs)

    If LinksTreeView.CheckedNodes.Count > 0 Then

      ' Clear the message label.
      Message.Text = "You selected: <br><br>"

      ' Iterate through the CheckedNodes collection and display the
 selected nodes.
      Dim node As TreeNode
      
      For Each node In LinksTreeView.CheckedNodes

        Message.Text &= node.Text & "<br>"

      Next

    Else

      Message.Text = "No items selected."

    End If

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView ShowCheckBoxes Example</h3>
    
      <!-- Set the ShowCheckBoxes property
 declaratively.   -->
      <!-- Because the ShowCheckBoxes property uses a flag
  -->
      <!-- enumeration, you can combine multiple values by  -->
      <!-- using the bitwise OR operator. In
 declarative    -->
      <!-- syntax, this is done using a comma separated   
  -->
      <!-- list.                                            -->
      <asp:TreeView id="LinksTreeView"
        Font-Name= "Arial"
        ForeColor="Blue"
        InitialExpandDepth="2"
        ShowCheckBoxes="Parent,Leaf" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10"
 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5"
 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5"
 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10"
 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <br><br>
      
      <asp:Button id="Submit"
        Text="Select Items"
        OnClick="Button_Click"  
        runat="server"/>
         
      <br><br>
      
      <asp:Label id="Message"
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="C#" %>

<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    if(LinksTreeView.CheckedNodes.Count > 0)
    {

      // Clear the message label.
      Message.Text = "You selected: <br><br>";

      // Iterate through the CheckedNodes collection and display the
 selected nodes.
      foreach (TreeNode node in LinksTreeView.CheckedNodes)
      {

        Message.Text += node.Text + "<br>";

      }

    }

    else
    {

      Message.Text = "No items selected.";

    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView ShowCheckBoxes Example</h3>
    
      <!-- Set the ShowCheckBoxes property declaratively.   -->
      <!-- Because the ShowCheckBoxes property uses a flag  -->
      <!-- enumeration, you can combine multiple values by  -->
      <!-- using the bitwise OR operator. In declarative  
  -->
      <!-- syntax, this is done using a
 comma separated     -->
      <!-- list.                                            -->
      <asp:TreeView id="LinksTreeView"
        Font-Name= "Arial"
        ForeColor="Blue"
        InitialExpandDepth="2"
        ShowCheckBoxes="Parent,Leaf" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <br><br>
      
      <asp:Button id="Submit"
        Text="Select Items"
        OnClick="Button_Click"  
        runat="server"/>
         
      <br><br>
      
      <asp:Label id="Message"
        runat="server"/>

    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeView クラス
TreeView メンバ
System.Web.UI.WebControls 名前空間
TreeNodeTypes 列挙
TreeView.SelectedNode プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からTreeView.ShowCheckBoxes プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTreeView.ShowCheckBoxes プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTreeView.ShowCheckBoxes プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「TreeView.ShowCheckBoxes プロパティ」の関連用語

TreeView.ShowCheckBoxes プロパティのお隣キーワード
検索ランキング

   

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



TreeView.ShowCheckBoxes プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS