TreeView.SelectedNodeStyle プロパティ
アセンブリ: System.Web (system.web.dll 内)

TreeView コントロールで選択されたノードのスタイルを表す TreeNodeStyle。既定値は null 参照 (Visual Basic では Nothing) で、SelectedNodeStyle プロパティが設定されていないことを示します。

SelectedNodeStyle プロパティを使用して、TreeView コントロールで選択されたノードの外観を制御します。このプロパティは読み取り専用です。ただし、このプロパティが返す TreeNodeStyle オブジェクトのプロパティを設定することはできます。このプロパティは、Property-Subproperty の形式で、宣言によって設定できます。Subproperty には、TreeNodeStyle オブジェクトのプロパティを指定します (例 : SelectedNodeStyle-ForeColor)。Property.Subproperty の形式で、プロパティをプログラムによって設定することもできます (例 : SelectedNodeStyle.ForeColor)。通常、共通設定にはカスタムの背景色、前景色、フォントのプロパティ、およびノードのスペーシングが含まれます。スタイル プロパティは、次の優先順位に従って適用されます。

SelectedNodeStyle プロパティを使用して、TreeView コントロールで選択されたノードの外観を制御する方法を次のコード例に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub Select_Change(ByVal sender As Object, ByVal e As EventArgs) Message.Text = "You selected: " & LinksTreeView.SelectedNode.Text End Sub </script> <html> <body> <form runat="server"> <h3>TreeView SelectedNodeStyle Example</h3> <asp:TreeView id="LinksTreeView" Font-Name= "Arial" ForeColor="Blue" SelectedNodeStyle-ForeColor="Green" SelectedNodeStyle-VerticalPadding="0" OnSelectedNodeChanged="Select_Change" 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> <br><br> <asp:Label id="Message" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Select_Change(Object sender, EventArgs e) { Message.Text = "You selected: " + LinksTreeView.SelectedNode.Text; } </script> <html> <body> <form runat="server"> <h3>TreeView SelectedNodeStyle Example</h3> <asp:TreeView id="LinksTreeView" Font-Name= "Arial" ForeColor="Blue" SelectedNodeStyle-ForeColor="Green" SelectedNodeStyle-VerticalPadding="0" OnSelectedNodeChanged="Select_Change" 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> <br><br> <asp:Label id="Message" runat="server"/> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からTreeView.SelectedNodeStyle プロパティを検索する場合は、下記のリンクをクリックしてください。

- TreeView.SelectedNodeStyle プロパティのページへのリンク