Bagikan melalui


TreeView.LeafNodeStyle Properti

Definisi

Mendapatkan referensi ke TreeNodeStyle objek yang memungkinkan Anda mengatur tampilan simpul daun.

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

Nilai Properti

Referensi ke TreeNodeStyle yang mewakili gaya simpul daun di TreeView.

Atribut

Contoh

Contoh kode berikut menunjukkan cara menggunakan LeafNodeStyle properti untuk mengontrol tampilan simpul daun dalam TreeView kontrol.


<%@ 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 LeafNodeStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView LeafNodeStyle Example</h3>
      
      <!-- Declaratively set the LeafNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        LeafNodeStyle-ForeColor="Green"
        LeafNodeStyle-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="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 LeafNodeStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView LeafNodeStyle Example</h3>
      
      <!-- Declaratively set the LeafNodeStyle settings. --> 
      <asp:TreeView id="LinksTreeView"
        LeafNodeStyle-ForeColor="Green"
        LeafNodeStyle-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>

Keterangan

LeafNodeStyle Gunakan properti untuk mengontrol tampilan simpul daun dalam TreeView kontrol. Properti ini bersifat baca-saja; namun, Anda dapat mengatur properti objek yang TreeNodeStyle dikembalikannya. Properti dapat diatur secara deklaratif dalam formulir Property-Subproperty, di mana Subproperty adalah properti TreeNodeStyle objek (misalnya, LeafNodeStyle-ForeColor). Properti juga dapat diatur secara terprogram dalam formulir Property.Subproperty (misalnya, LeafNodeStyle.ForeColor). Pengaturan umum biasanya mencakup warna latar belakang kustom, warna latar depan, properti font, dan penspasian simpul. Properti gaya diterapkan dalam urutan prioritas berikut:

  1. NodeStyle.

  2. RootNodeStyle, , ParentNodeStyleatau LeafNodeStyle, tergantung pada jenis node. LevelStyles Jika koleksi didefinisikan, koleksi diterapkan saat ini, mengambil alih properti gaya node lainnya.

  3. SelectedNodeStyle.

  4. HoverNodeStyle.

Jika Anda perlu membuat menu navigasi gaya daftar isi di mana simpul pada tingkat tertentu harus memiliki tampilan yang sama, terlepas dari apakah mereka memiliki simpul anak, Anda mungkin mempertimbangkan untuk menggunakan LevelStyles properti alih-alih mengatur properti gaya individual.

Berlaku untuk

Lihat juga