TreeView.LevelStyles プロパティ

定義

ノードのスタイルをツリーのレベル別に表す Style オブジェクトのコレクションを取得します。

public:
 property System::Web::UI::WebControls::TreeNodeStyleCollection ^ LevelStyles { System::Web::UI::WebControls::TreeNodeStyleCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TreeNodeStyleCollection LevelStyles { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.LevelStyles : System.Web.UI.WebControls.TreeNodeStyleCollection
Public ReadOnly Property LevelStyles As TreeNodeStyleCollection

プロパティ値

ノードのスタイルをツリーのレベル別に表す StyleCollection

属性

次のコード例では、 プロパティを使用 LevelStyles してナビゲーション メニューを作成する方法を示します。 コントロールは常に完全に展開され、展開ノードのインジケーターとイメージは非表示になります。 また、 ChildNodesPadding プロパティは、ノード レベルの間隔を制御するために使用されます。


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

  <head runat="server">
    <title>TreeView LevelStyles Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView LevelStyles Example</h3>

      <!-- Populate the LevelStyles collection of the TreeView control -->
      <!-- declaratively.                                              -->
      
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ShowExpandCollapse="false"
        ExpandDepth="3"
        NodeIndent="0" 
        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>

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

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

  <head runat="server">
    <title>TreeView LevelStyles Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView LevelStyles Example</h3>

      <!-- Populate the LevelStyles collection of the TreeView control -->
      <!-- declaratively.                                              -->
      
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ShowExpandCollapse="false"
        ExpandDepth="3"
        NodeIndent="0" 
        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>

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

注釈

ツリーの個々の LevelStyles レベルでノードのスタイルを制御するには、 コレクションを個々のスタイル プロパティ (プロパティなど NodeStyle ) の代わりに使用します。 コレクションの最初のスタイルは、ツリーの最初のレベルのノードのスタイルに対応します。 コレクション内の 2 番目のスタイルは、ツリーの 2 番目のレベルのノードのスタイルに対応しています。 このプロパティは、ほとんどの場合、子ノードがあるかどうかに関係なく、特定のレベルのノードの外観が同じである必要がある目次スタイルのナビゲーション メニューを生成するために使用されます。

スタイル プロパティは、次の順序で適用されます。

  1. NodeStyle.

  2. RootNodeStyleParentNodeStyle、、または LeafNodeStyleノードの種類に応じて。 コレクションが LevelStyles 定義されている場合は、現時点で適用され、他のノード スタイル プロパティがオーバーライドされます。

  3. SelectedNodeStyle.

  4. HoverNodeStyle

適用対象

こちらもご覧ください