TreeView.LevelStyles TreeView.LevelStyles TreeView.LevelStyles TreeView.LevelStyles Property

Definizione

Ottiene un insieme di oggetti Style che rappresentano gli stili dei nodi nei singoli livelli della struttura ad albero.Gets a collection of Style objects that represent the node styles at the individual levels of the tree.

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; }
member this.LevelStyles : System.Web.UI.WebControls.TreeNodeStyleCollection
Public ReadOnly Property LevelStyles As TreeNodeStyleCollection

Valore della proprietà

Oggetto StyleCollection che rappresenta gli stili dei nodi nei singoli livelli della struttura ad albero.A StyleCollection that represents the node styles at the individual levels of the tree.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato LevelStyles come utilizzare la proprietà per creare un menu di navigazione.The following code example demonstrates how to use the LevelStyles property to create a navigation menu. Il controllo viene sempre espanso completamente, con gli indicatori del nodo di espansione e le immagini nascoste.The control is always fully expanded, with the expansion node indicators and images hidden. Inoltre, la ChildNodesPadding proprietà viene utilizzata per controllare la spaziatura dei livelli del nodo.Also, the ChildNodesPadding property is used to control the spacing of the node levels.


<%@ 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>

Commenti

Usare la LevelStyles raccolta come alternativa alle singole proprietà di stile, ad esempio la NodeStyle proprietà, per controllare lo stile dei nodi a singoli livelli dell'albero.Use the LevelStyles collection as an alternative to the individual style properties (such as the NodeStyle property) to control the style of nodes at the individual levels of the tree. Il primo stile della raccolta corrisponde allo stile dei nodi nel primo livello dell'albero.The first style in the collection corresponds to the style of nodes in the first level of the tree. Il secondo stile della raccolta corrisponde allo stile dei nodi nel secondo livello della struttura ad albero e così via.The second style in the collection corresponds to the style of nodes in the second level of the tree, and so on. Questa proprietà viene spesso usata per generare i menu di navigazione in stile sommario in cui i nodi a un determinato livello devono avere lo stesso aspetto, indipendentemente dal fatto che abbiano nodi figlio.This property is most often used to generate table of contents-style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes.

Le proprietà di stile vengono applicate nell'ordine seguente:Style properties are applied in the following order:

  1. NodeStyle.NodeStyle.

  2. RootNodeStyle, ParentNodeStyle oLeafNodeStyle, a seconda del tipo di nodo.RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type. Se la LevelStyles raccolta è definita, viene applicata in questo momento, sostituendo le altre proprietà dello stile del nodo.If the LevelStyles collection is defined, it is applied at this time, overriding the other node style properties.

  3. SelectedNodeStyle.SelectedNodeStyle.

  4. HoverNodeStyle

Si applica a

Vedi anche