TreeView.ParentNodeStyle プロパティ

定義

TreeNodeStyle コントロールの親ノードの外観を設定できる TreeView オブジェクトへの参照を取得します。

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

プロパティ値

TreeNodeStyle コントロールの親ノードのスタイルを表す TreeView への参照。

属性

次のコード例では、 プロパティを使用 ParentNodeStyle して、コントロール内の親ノードの外観を制御する方法を TreeView 示します。


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

注釈

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

  1. NodeStyle.

  2. RootNodeStyleParentNodeStyle、または LeafNodeStyleは、ノードの種類に応じて異なります。 コレクションが LevelStyles 定義されている場合、この時点で適用され、他のノード スタイル プロパティがオーバーライドされます。

  3. SelectedNodeStyle.

  4. HoverNodeStyle.

特定のレベルのノードが子ノードを持っているかどうかにかかわらず、同じ外観にする必要がある目次スタイルのナビゲーション メニューを生成する必要がある場合は、個々のスタイル プロパティを設定する代わりに、 プロパティの使用 LevelStyles を検討してください。

適用対象

こちらもご覧ください