TreeView.LevelStyles Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan kumpulan Style objek yang mewakili gaya simpul di tingkat pohon individual.
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
Nilai Properti
StyleCollection yang mewakili gaya simpul di tingkat pohon individual.
- Atribut
Contoh
Contoh kode berikut menunjukkan cara menggunakan LevelStyles properti untuk membuat menu navigasi. Kontrol selalu diperluas sepenuhnya, dengan indikator node ekspansi dan gambar tersembunyi. Selain itu ChildNodesPadding , properti digunakan untuk mengontrol penspasian tingkat simpul.
<%@ 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>
Keterangan
LevelStyles Gunakan koleksi sebagai alternatif untuk properti gaya individu (seperti NodeStyle properti) untuk mengontrol gaya simpul di tingkat pohon individual. Gaya pertama dalam koleksi sesuai dengan gaya simpul di tingkat pertama pohon. Gaya kedua dalam koleksi sesuai dengan gaya simpul di tingkat kedua pohon, dan sebagainya. Properti ini paling sering digunakan untuk menghasilkan menu navigasi gaya daftar isi di mana simpul pada tingkat tertentu harus memiliki penampilan yang sama, terlepas dari apakah mereka memiliki simpul anak.
Properti gaya diterapkan dalam urutan berikut:
RootNodeStyle, , ParentNodeStyleatau LeafNodeStyle, tergantung pada jenis node. LevelStyles Jika koleksi didefinisikan, koleksi diterapkan saat ini, mengambil alih properti gaya node lainnya.