TreeNodeStyleCollection 類別

定義

代表 TreeView 控制項中的 TreeNodeStyle 物件集合。Represents a collection of TreeNodeStyle objects that is in a TreeView control.

public ref class TreeNodeStyleCollection sealed : System::Web::UI::StateManagedCollection
public sealed class TreeNodeStyleCollection : System.Web.UI.StateManagedCollection
type TreeNodeStyleCollection = class
    inherit StateManagedCollection
Public NotInheritable Class TreeNodeStyleCollection
Inherits StateManagedCollection
繼承
TreeNodeStyleCollection

範例

下列程式碼範例示範如何使用 TreeNodeStyleCollection 類別來指定控制項之個別層級的樣式設定 TreeViewThe following code example demonstrates how to use the TreeNodeStyleCollection class to specify the style settings for the individual levels of a TreeView control. 請注意, LevelStyles 屬性會傳回 TreeNodeStyleCollection 物件。Notice that the LevelStyles property returns a TreeNodeStyleCollection object.


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

備註

TreeNodeStyleCollection類別是用來儲存和管理物件的集合 TreeNodeStyleThe TreeNodeStyleCollection class is used to store and manage a collection of TreeNodeStyle objects. LevelStyles類型的屬性會 TreeNodeStyleCollection 儲存樹狀結構之個別層級的節點樣式。The LevelStyles property, of type TreeNodeStyleCollection, stores the node styles for the individual levels of a tree.

LevelStyles屬性是個別樣式屬性(例如屬性)的替代方式,可 NodeStyle 控制樹狀結構不同層級的節點樣式。The LevelStyles property is an alternative to the individual style properties, such as the NodeStyle property, that control node styles at different levels of the tree. 集合中的第一個樣式會對應到樹狀結構第一個層級中的節點樣式。The first style in the collection corresponds to the node style in the first level of the tree. 集合中的第二個樣式會對應到樹狀結構第二個層級中的節點樣式,依此類推。The second style in the collection corresponds to the node style in the second level of the tree, and so on. LevelStyles屬性最常用於產生目錄樣式的導覽功能表,其中特定層級的節點應該具有相同的外觀,不論它們是否有子節點。The LevelStyles 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.

TreeNodeStyleCollection類別會從類別繼承其大部分的成員 StateManagedCollectionThe TreeNodeStyleCollection class inherits most of its members from the StateManagedCollection class. 如需繼承成員的詳細資訊,請參閱 StateManagedCollectionFor more information about the inherited members, see StateManagedCollection.

屬性

Count

取得 StateManagedCollection 集合中所包含的項目數。Gets the number of elements contained in the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
Item[Int32]

取得或設定位於 TreeNodeStyle 物件中所指定索引處的 TreeNodeStyleCollection 物件。Gets or sets the TreeNodeStyle object at the specified index in the TreeNodeStyleCollection object.

方法

Add(TreeNodeStyle)

將指定的 TreeNodeStyle 物件附加至 TreeNodeStyleCollection 物件的結尾。Appends the specified TreeNodeStyle object to the end of the TreeNodeStyleCollection object.

Clear()

將所有項目從 StateManagedCollection 集合中移除。Removes all items from the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
Contains(TreeNodeStyle)

判斷指定的 TreeNodeStyle 物件是否在集合中。Determines whether the specified TreeNodeStyle object is in the collection.

CopyTo(Array, Int32)

從特定的陣列索引開始,將 StateManagedCollection 集合的項目複製到陣列。Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index.

(繼承來源 StateManagedCollection)
CopyTo(TreeNodeStyle[], Int32)

從目標陣列中的指定索引開始,從 TreeNodeStyleCollection 物件中,將所有項目複製至相容的一維陣列 TreeNodeStyle 物件。Copies all the items from the TreeNodeStyleCollection object to a compatible one-dimensional array of TreeNodeStyle objects, starting at the specified index in the target array.

CreateKnownType(Int32)

在衍生類別中覆寫時,建立實作 IStateManager 之類別的執行個體。When overridden in a derived class, creates an instance of a class that implements IStateManager. 根據 GetKnownTypes() 方法所傳回之集合指定的成員,建立物件的類型。The type of object created is based on the specified member of the collection returned by the GetKnownTypes() method.

(繼承來源 StateManagedCollection)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回逐一查看 StateManagedCollection 集合的列舉值。Returns an iterator that iterates through the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetKnownTypes()

在衍生類別中覆寫時,取得 StateManagedCollection 集合可以包含之 IStateManager 類型的陣列。When overridden in a derived class, gets an array of IStateManager types that the StateManagedCollection collection can contain.

(繼承來源 StateManagedCollection)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(TreeNodeStyle)

判斷集合中指定之 TreeNodeStyle 物件的索引。Determines the index of the specified TreeNodeStyle object in the collection.

Insert(Int32, TreeNodeStyle)

將指定的 TreeNodeStyle 物件插入 TreeNodeStyleCollection 物件的指定索引位置。Inserts the specified TreeNodeStyle object into the TreeNodeStyleCollection object at the specified index location.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnClear()

在衍生類別中覆寫時,在 Clear() 方法移除集合的所有項目之前,執行額外工作。When overridden in a derived class, performs additional work before the Clear() method removes all items from the collection.

(繼承來源 StateManagedCollection)
OnClearComplete()

在衍生類別中覆寫時,在 Clear() 方法完成移除集合的所有項目之後,執行額外工作。When overridden in a derived class, performs additional work after the Clear() method finishes removing all items from the collection.

(繼承來源 StateManagedCollection)
OnInsert(Int32, Object)

在衍生類別中覆寫時,在 IList.Insert(Int32, Object)IList.Add(Object) 方法將項目加入集合之前,執行額外工作。When overridden in a derived class, performs additional work before the IList.Insert(Int32, Object) or IList.Add(Object) method adds an item to the collection.

(繼承來源 StateManagedCollection)
OnInsertComplete(Int32, Object)

在衍生類別中覆寫時,在 IList.Insert(Int32, Object)IList.Add(Object) 方法將項目加入集合之後,執行額外工作。When overridden in a derived class, performs additional work after the IList.Insert(Int32, Object) or IList.Add(Object) method adds an item to the collection.

(繼承來源 StateManagedCollection)
OnRemove(Int32, Object)

在衍生類別中覆寫時,在 IList.Remove(Object)IList.RemoveAt(Int32) 方法從集合中移除指定的項目之前,執行額外工作。When overridden in a derived class, performs additional work before the IList.Remove(Object) or IList.RemoveAt(Int32) method removes the specified item from the collection.

(繼承來源 StateManagedCollection)
OnRemoveComplete(Int32, Object)

在衍生類別中覆寫時,在 IList.Remove(Object)IList.RemoveAt(Int32) 方法從集合中移除指定的項目之後,執行額外工作。When overridden in a derived class, performs additional work after the IList.Remove(Object) or IList.RemoveAt(Int32) method removes the specified item from the collection.

(繼承來源 StateManagedCollection)
OnValidate(Object)

在衍生類別中覆寫時,驗證 StateManagedCollection 集合的項目。When overridden in a derived class, validates an element of the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
Remove(TreeNodeStyle)

TreeNodeStyle 物件移除指定的 TreeNodeStyleCollection 物件。Removes the specified TreeNodeStyle object from the TreeNodeStyleCollection object.

RemoveAt(Int32)

TreeNodeStyle 物件的指定索引位置移除 TreeNodeStyleCollection 物件。Removes the TreeNodeStyle object at the specified index location from the TreeNodeStyleCollection object.

SetDirty()

強制整個 StateManagedCollection 集合序列化至檢視狀態。Forces the entire StateManagedCollection collection to be serialized into view state.

(繼承來源 StateManagedCollection)
SetDirtyObject(Object)

在衍生類別中覆寫時,指示集合中所包含的 object,將其完整狀態 (而不只是變更資訊) 記錄至檢視狀態。When overridden in a derived class, instructs an object contained by the collection to record its entire state to view state, rather than recording only change information.

(繼承來源 StateManagedCollection)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.Count

取得 StateManagedCollection 集合中所包含的項目數。Gets the number of elements contained in the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
ICollection.IsSynchronized

取得值,表示 StateManagedCollection 集合是否為同步 (安全執行緒)。Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). 在所有情況下,這個方法都會傳回 falseThis method returns false in all cases.

(繼承來源 StateManagedCollection)
ICollection.SyncRoot

取得物件,可用來同步處理對 StateManagedCollection 集合的存取。Gets an object that can be used to synchronize access to the StateManagedCollection collection. 在所有情況下,這個方法都會傳回 nullThis method returns null in all cases.

(繼承來源 StateManagedCollection)
IEnumerable.GetEnumerator()

傳回逐一查看 StateManagedCollection 集合的列舉值。Returns an iterator that iterates through the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
IList.Add(Object)

將項目加入 StateManagedCollection 集合。Adds an item to the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
IList.Clear()

將所有項目從 StateManagedCollection 集合中移除。Removes all items from the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
IList.Contains(Object)

判斷 StateManagedCollection 集合是否包含特定值。Determines whether the StateManagedCollection collection contains a specific value.

(繼承來源 StateManagedCollection)
IList.IndexOf(Object)

判斷 StateManagedCollection 集合中指定之項目的索引。Determines the index of a specified item in the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
IList.Insert(Int32, Object)

將項目插入位於指定索引處的 StateManagedCollection 集合中。Inserts an item into the StateManagedCollection collection at the specified index.

(繼承來源 StateManagedCollection)
IList.IsFixedSize

取得值,表示 StateManagedCollection 集合是否具有固定大小。Gets a value indicating whether the StateManagedCollection collection has a fixed size. 在所有情況下,這個方法都會傳回 falseThis method returns false in all cases.

(繼承來源 StateManagedCollection)
IList.IsReadOnly

取得值,表示 StateManagedCollection 集合是否為唯讀。Gets a value indicating whether the StateManagedCollection collection is read-only.

(繼承來源 StateManagedCollection)
IList.Item[Int32]

取得指定索引處的 IStateManager 項目。Gets the IStateManager element at the specified index.

(繼承來源 StateManagedCollection)
IList.Remove(Object)

StateManagedCollection 集合中移除指定物件的第一個符合項目。Removes the first occurrence of the specified object from the StateManagedCollection collection.

(繼承來源 StateManagedCollection)
IList.RemoveAt(Int32)

移除指定索引處的 IStateManager 項目。Removes the IStateManager element at the specified index.

(繼承來源 StateManagedCollection)
IStateManager.IsTrackingViewState

取得值,表示 StateManagedCollection 集合是否正在儲存變更至檢視狀態。Gets a value indicating whether the StateManagedCollection collection is saving changes to its view state.

(繼承來源 StateManagedCollection)
IStateManager.LoadViewState(Object)

還原先前儲存之 StateManagedCollection 集合和內含 IStateManager 項目的檢視狀態。Restores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains.

(繼承來源 StateManagedCollection)
IStateManager.SaveViewState()

儲存自頁面回傳至伺服器以來 StateManagedCollection 集合和每個內含 IStateManager 物件的變更。Saves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server.

(繼承來源 StateManagedCollection)
IStateManager.TrackViewState()

使得 StateManagedCollection 集合和每個內含 IStateManager 物件追蹤其檢視狀態的變更,以便跨相同頁面要求保存這些變更。Causes the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page.

(繼承來源 StateManagedCollection)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱