TreeNodeStyleCollection クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説TreeNodeStyleCollection クラスは、TreeNodeStyle オブジェクトのコレクションの格納と管理に使用されます。TreeNodeStyleCollection 型の LevelStyles プロパティは、ツリーの各レベルのノード スタイルを格納します。
LevelStyles プロパティは、NodeStyle プロパティのような、ツリーのさまざまなレベルでノード スタイルを制御する個別のスタイル プロパティの代わりに使用できます。このコレクションの中の最初のスタイルは、ツリーの最初のレベルのノードのスタイルに対応します。このコレクションの中の 2 番目のスタイルは、ツリーの 2 番目のレベルのノードのスタイルに対応し、以下同様に対応します。子ノードの有無にかかわらず、特定のレベルにあるノードの外観を同じにする場合は、LevelStyles プロパティを使用してコンテンツ スタイル ナビゲーション メニューのテーブルを生成する方法が最も一般的です。
TreeNodeStyleCollection クラスは、StateManagedCollection クラスのほとんどのメンバを継承します。継承されるメンバの詳細については、「StateManagedCollection」を参照してください。
使用例TreeNodeStyleCollection クラスを使用して、TreeView コントロールの各レベルに対してスタイル設定を個別に指定するコード例を次に示します。LevelStyles プロパティは、TreeNodeStyleCollection オブジェクトを返します。
<%@ Page Language="VB" %> <html> <body> <form runat="server"> <h3>TreeView LevelStyles Example</h3> <!-- Populate the LevelStyles collection of the TreeView control --> <!-- declaratively. --> <asp:TreeView id="LinksTreeView" Font-Name= "Arial" ForeColor="Blue" ShowExpandCollapse="false" InitialExpandDepth="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="C#" %> <html> <body> <form runat="server"> <h3>TreeView LevelStyles Example</h3> <!-- Populate the LevelStyles collection of the TreeView control --> <!-- declaratively. --> <asp:TreeView id="LinksTreeView" Font-Name= "Arial" ForeColor="Blue" ShowExpandCollapse="false" InitialExpandDepth="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>
継承階層System.Web.UI.StateManagedCollection
System.Web.UI.WebControls.TreeNodeStyleCollection
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照TreeNodeStyleCollection プロパティ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| Count | StateManagedCollection コレクションに格納されている要素の数を取得します。 ( StateManagedCollection から継承されます。) |
| Item | TreeNodeStyleCollection オブジェクト内の指定したインデックス位置にある TreeNodeStyle オブジェクトを取得または設定します。 |
参照TreeNodeStyleCollection メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Add | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトの末尾に追加します。 |
| Clear | StateManagedCollection コレクションからすべての項目を削除します。 ( StateManagedCollection から継承されます。) |
| Contains | 指定した TreeNodeStyle オブジェクトがコレクション内にあるかどうかを確認します。 |
| CopyTo | オーバーロードされます。 TreeNodeStyleCollection オブジェクトからすべての項目をコピーします。 |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
| GetEnumerator | StateManagedCollection コレクションを反復処理する反復子を返します。 ( StateManagedCollection から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| IndexOf | コレクション内の指定した TreeNodeStyle オブジェクトのインデックスを確認します。 |
| Insert | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトの指定したインデックス位置に挿入します。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| Remove | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトから削除します。 |
| RemoveAt | 指定したインデックス位置にある TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトから削除します。 |
| SetDirty | 強制的に StateManagedCollection コレクション全体をビューステートにシリアル化します。 ( StateManagedCollection から継承されます。) |
| ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照TreeNodeStyleCollection メンバ
TreeView コントロール内の TreeNodeStyle オブジェクトのコレクションを表します。
TreeNodeStyleCollection データ型で公開されるメンバを以下の表に示します。
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| Count | StateManagedCollection コレクションに格納されている要素の数を取得します。(StateManagedCollection から継承されます。) |
| Item | TreeNodeStyleCollection オブジェクト内の指定したインデックス位置にある TreeNodeStyle オブジェクトを取得または設定します。 |
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Add | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトの末尾に追加します。 |
| Clear | StateManagedCollection コレクションからすべての項目を削除します。 (StateManagedCollection から継承されます。) |
| Contains | 指定した TreeNodeStyle オブジェクトがコレクション内にあるかどうかを確認します。 |
| CopyTo | オーバーロードされます。 TreeNodeStyleCollection オブジェクトからすべての項目をコピーします。 |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
| GetEnumerator | StateManagedCollection コレクションを反復処理する反復子を返します。 (StateManagedCollection から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| IndexOf | コレクション内の指定した TreeNodeStyle オブジェクトのインデックスを確認します。 |
| Insert | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトの指定したインデックス位置に挿入します。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| Remove | 指定した TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトから削除します。 |
| RemoveAt | 指定したインデックス位置にある TreeNodeStyle オブジェクトを TreeNodeStyleCollection オブジェクトから削除します。 |
| SetDirty | 強制的に StateManagedCollection コレクション全体をビューステートにシリアル化します。 (StateManagedCollection から継承されます。) |
| ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照- TreeNodeStyleCollectionのページへのリンク