다음을 통해 공유


TreeView.RootNodeStyle 속성

정의

컨트롤에서 루트 노드의 TreeNodeStyle 모양을 설정할 수 있는 개체에 대한 참조를 TreeView 가져옵니다.

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

속성 값

에 있는 TreeNodeStyle 루트 노드 TreeView의 스타일을 나타내는 참조입니다.

특성

예제

다음 코드 예제에서는 컨트롤에서 RootNodeStyle 루트 노드 TreeView 의 모양을 제어 하는 속성을 사용 하는 방법을 보여 줍니다.


<%@ 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 RootNodeStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView RootNodeStyle Example</h3>
      
      <!-- Declaratively set the RootNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        RootNodeStyle-ForeColor="Green"
        RootNodeStyle-VerticalPadding="0"  
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="Content" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="Content">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="Content"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="Content">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </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 RootNodeStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView RootNodeStyle Example</h3>
      
      <!-- Declaratively set the RootNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        RootNodeStyle-ForeColor="Green"
        RootNodeStyle-VerticalPadding="0"  
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="Content" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="Content">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="Content"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="Content">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>

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

설명

컨트롤에서 RootNodeStyle 루트 노드 TreeView 의 모양을 제어 하려면 속성을 사용 합니다. 이 속성은 읽기 전용입니다. 그러나 반환하는 개체의 TreeNodeStyle 속성을 설정할 수 있습니다. 속성은 개체의 TreeNodeStyle 속성(예RootNodeStyle-ForeColor: )인 형식 Property-SubpropertySubproperty 에서 선언적으로 설정할 수 있습니다. 속성은 양식 Property.Subproperty 에서 프로그래밍 방식으로 설정할 수도 있습니다(예: RootNodeStyle.ForeColor). 일반적인 설정에는 일반적으로 사용자 지정 배경색, 전경색, 글꼴 속성 및 노드 간격이 포함됩니다. 스타일 속성은 다음 우선 순위 순서로 적용됩니다.

  1. NodeStyle;

  2. RootNodeStyle, ParentNodeStyle또는 LeafNodeStyle노드 유형에 따라 다릅니다. 컬렉션이 LevelStyles 정의되면 이때 적용되어 다른 노드 스타일 속성을 재정의합니다.

  3. SelectedNodeStyle

  4. HoverNodeStyle;

자식 노드가 있는지 여부에 관계없이 특정 수준의 노드가 동일한 모양을 가져야 하는 목차 스타일 탐색 메뉴 테이블을 생성해야 하는 경우 개별 스타일 속성을 설정하는 대신 속성을 사용하는 LevelStyles 것이 좋습니다.

적용 대상

추가 정보