TreeNodeStyle クラスとは? わかりやすく解説

TreeNodeStyle クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

TreeView コントロールノードスタイル表します

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

Public NotInheritable Class
 TreeNodeStyle
    Inherits Style
Dim instance As TreeNodeStyle
public sealed class TreeNodeStyle : Style
public final class TreeNodeStyle extends Style
public final class TreeNodeStyle extends
 Style
解説解説

TreeNodeStyle クラス使用してTreeView コントロールノードスタイル表しますTreeView コントロールでは、各種ノード タイプに対してさまざまなスタイル特性 (フォントサイズや色など) を指定できます

TreeNodeStyle クラスサポートされノード スタイル次の表に示します

TreeView コントロールノード スタイル プロパティ設定する場合、これらのプロパティ次の順序適用されます。

  1. NodeStyle.

  2. ノードに応じてRootNodeStyleParentNodeStyle、または LeafNodeStyle

  3. LevelStyles.

  4. SelectedNodeStyle.

  5. HoverNodeStyle.

TreeNodeStyle クラスは、Style クラスのほとんどのメンバ継承します。このクラスは、ノードテキスト周囲余白サイズおよび隣接するノード間の間隔を制御するプロパティ提供することによって、Style クラス拡張します。HorizontalPadding プロパティ使用してノードテキスト左右にある余白サイズ制御します同様に、VerticalPadding プロパティノードテキストの上下にある余白サイズ制御しますTreeNodeStyle適用対象となるノードとそのノード隣接するノード間隔は、NodeSpacing プロパティ設定することによって制御できます親ノード子ノード間隔制御するには、ChildNodesPadding プロパティ使用します

継承されるスタイル設定詳細については、Styleトピック参照してください

使用例使用例

ParentNodeStyle プロパティから返される TreeNodeStyle オブジェクトスタイル プロパティ設定してTreeView コントロール親ノード外観制御するコード方法次のコード例示します

<%@ Page Language="VB" %>

<script runat="server">

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

    ' Programmatically set the HorizontalPadding property based on the
 
    ' user's selection.
    ItemsTreeView.ParentNodeStyle.HorizontalPadding = Convert.ToInt32(HorizontalPaddingList.SelectedItem.Text)

  End Sub

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

    ' Programmatically set the VerticalPadding property based on the
 
    ' user's selection.
    ItemsTreeView.ParentNodeStyle.VerticalPadding = Convert.ToInt32(VerticalPaddingList.SelectedItem.Text)

  End Sub

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

    ' Programmatically set the NodeSpacing property based on the 
    ' user's selection.
    ItemsTreeView.ParentNodeStyle.NodeSpacing = Convert.ToInt32(NodeSpacingList.SelectedItem.Text)

  End Sub

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

    ' Programmatically set the ChildNodesPadding property based on the
 
    ' user's selection.
    ItemsTreeView.ParentNodeStyle.ChildNodesPadding = Convert.ToInt32(ChildNodesPaddingList.SelectedItem.Text)

  End Sub

</script>

<html>
  <body>  
    <form runat="server">
    
      <h3>TreeNodeStyle Example</h3>
      
      <!-- Set the styles for the leaf nodes
 declaratively. -->
      <asp:TreeView id="ItemsTreeView"
        Font-Name= "Arial"
        ForeColor="Blue"
        ParentNodeStyle-ForeColor="Green"
        ParentNodeStyle-HorizontalPadding="5" 
        ParentNodeStyle-VerticalPadding="5"  
        ParentNodeStyle-NodeSpacing="5"
        ParentNodeStyle-ChildNodesPadding="5"
        InitialExpandDepth="4"  
        runat="server">
         
        <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>
        
        </Nodes>
        
      </asp:TreeView>
      
      <hr>
      
      <h5>Select the style settings for the parent nodes.</h5>
      
      <table cellpadding="5">
      
        <tr align="right">
        
          <td>
          
            Horizontal Padding:
          
            <asp:DropDownList id="HorizontalPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="HorizontalPadding_Changed"
 
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
          <td>
          
            Vertical Padding:
          
            <asp:DropDownList id="VerticalPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="VerticalPadding_Changed"
 
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
        </tr>
        
        <tr align="right">
        
          <td>
          
            Node Spacing:
          
            <asp:DropDownList id="NodeSpacingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="NodeSpacing_Changed"
   
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
          <td>
          
            Child Nodes Padding:
          
            <asp:DropDownList id="ChildNodesPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="ChildNodePadding_Changed"
  
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
        
        </tr>
      
      </table>
       
    </form>
  </body>
</html>

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

<script runat="server">

  void HorizontalPadding_Changed(Object sender, EventArgs e)
  {

    // Programmatically set the HorizontalPadding property based on
 the 
    // user's selection.
    ItemsTreeView.ParentNodeStyle.HorizontalPadding = Convert.ToInt32(HorizontalPaddingList.SelectedItem.Text);

  }

  void VerticalPadding_Changed(Object sender, EventArgs e)
  {

    // Programmatically set the VerticalPadding property based on the
 
    // user's selection.
    ItemsTreeView.ParentNodeStyle.VerticalPadding = Convert.ToInt32(VerticalPaddingList.SelectedItem.Text);

  }

  void NodeSpacing_Changed(Object sender, EventArgs e)
  {

    // Programmatically set the NodeSpacing property based on the 
    // user's selection.
    ItemsTreeView.ParentNodeStyle.NodeSpacing = Convert.ToInt32(NodeSpacingList.SelectedItem.Text);

  }

  void ChildNodePadding_Changed(Object sender, EventArgs e)
  {

    // Programmatically set the ChildNodesPadding property based on
 the 
    // user's selection.
    ItemsTreeView.ParentNodeStyle.ChildNodesPadding = Convert.ToInt32(ChildNodesPaddingList.SelectedItem.Text);

  }

</script>

<html>
  <body>  
    <form runat="server">
    
      <h3>TreeNodeStyle Example</h3>
      
      <!-- Set the styles for the leaf nodes declaratively.
 -->
      <asp:TreeView id="ItemsTreeView"
        Font-Name= "Arial"
        ForeColor="Blue"
        ParentNodeStyle-ForeColor="Green"
        ParentNodeStyle-HorizontalPadding="5" 
        ParentNodeStyle-VerticalPadding="5"  
        ParentNodeStyle-NodeSpacing="5"
        ParentNodeStyle-ChildNodesPadding="5"
        InitialExpandDepth="4"  
        runat="server">
         
        <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>
        
        </Nodes>
        
      </asp:TreeView>
      
      <hr>
      
      <h5>Select the style settings for the parent nodes.</h5>
      
      <table cellpadding="5">
      
        <tr align="right">
        
          <td>
          
            Horizontal Padding:
          
            <asp:DropDownList id="HorizontalPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="HorizontalPadding_Changed" 
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
          <td>
          
            Vertical Padding:
          
            <asp:DropDownList id="VerticalPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="VerticalPadding_Changed" 
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
        </tr>
        
        <tr align="right">
        
          <td>
          
            Node Spacing:
          
            <asp:DropDownList id="NodeSpacingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="NodeSpacing_Changed"   
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
          
          <td>
          
            Child Nodes Padding:
          
            <asp:DropDownList id="ChildNodesPaddingList"
              AutoPostBack="true"
              OnSelectedIndexChanged="ChildNodePadding_Changed"  
              runat="server">
              
              <asp:ListItem>0</asp:ListItem>
              <asp:ListItem Selected="true">5</asp:ListItem>
              <asp:ListItem>10</asp:ListItem>
              
            </asp:DropDownList> 
          
          </td>
        
        </tr>
      
      </table>
       
    </form>
  </body>
</html>

継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Web.UI.WebControls.Style
        System.Web.UI.WebControls.TreeNodeStyle
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeNodeStyle メンバ
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
Style クラス
HoverNodeStyle
LeafNodeStyle
NodeStyle
ParentNodeStyle
RootNodeStyle
SelectedNodeStyle



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

辞書ショートカット

すべての辞書の索引

「TreeNodeStyle クラス」の関連用語

TreeNodeStyle クラスのお隣キーワード
検索ランキング

   

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



TreeNodeStyle クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS