TreeView.ExpandImageUrl プロパティ

定義

展開可能なノード インジケーターのカスタム イメージの URL を取得または設定します。

public:
 property System::String ^ ExpandImageUrl { System::String ^ get(); void set(System::String ^ value); };
public string ExpandImageUrl { get; set; }
member this.ExpandImageUrl : string with get, set
Public Property ExpandImageUrl As String

プロパティ値

String

展開可能なノードに表示されるカスタム イメージの URL。 既定値は空の文字列 ("") で、既定の正符号 (+) のイメージを表示します。

次のコード例では、このプロパティを使用 ExpandImageUrl して、展開可能ノード インジケーターのカスタム イメージを指定する方法を示します。 コード例を表示し、イメージをコントロールに表示するには、独自のイメージを指定する必要があり、プロパティを ImageSet に設定する TreeNodeImageSet.Custom必要があります。


<%@ 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 Custom Images Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Custom Images Example</h3>
      
      <!-- Set the custom images of this TreeView control -->
      <!-- declaratively.                                 -->
      <asp:TreeView id="CustomTreeView"
        NoExpandImageUrl="Space.jpg"
        CollapseImageUrl="Minus.jpg"
        CollapseImageToolTip="Collapse Node"
        ExpandImageUrl="Plus.jpg"
        ExpandImageToolTip="Expand Node"
        RootNodeStyle-ImageUrl="Root.jpg"
        ParentNodeStyle-ImageUrl="Parent.jpg"
        LeafNodeStyle-ImageUrl="Leaf.jpg" 
        ImageSet="Custom"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="_blank" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page 1"
              Target="_blank">
                 
              <asp:TreeNode Value="Section 1"
                ImageUrl="custom.jpg" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="_blank">
              </asp:TreeNode>
                
            </asp:TreeNode>
            
            <asp:TreeNode Value="Page 2" 
              Selected="True" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="_blank">
            </asp:TreeNode>
            
          </asp:TreeNode>
        
        </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 Custom Images Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Custom Images Example</h3>
      
      <!-- Set the custom images of this TreeView control -->
      <!-- declaratively.                                 -->
      <asp:TreeView id="CustomTreeView"
        NoExpandImageUrl="Space.jpg"
        CollapseImageUrl="Minus.jpg"
        CollapseImageToolTip="Collapse Node"
        ExpandImageUrl="Plus.jpg"
        ExpandImageToolTip="Expand Node"
        RootNodeStyle-ImageUrl="Root.jpg"
        ParentNodeStyle-ImageUrl="Parent.jpg"
        LeafNodeStyle-ImageUrl="Leaf.jpg" 
        ImageSet="Custom"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="_blank" 
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page 1"
              Target="_blank">
                 
              <asp:TreeNode Value="Section 1"
                ImageUrl="custom.jpg" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="_blank">
              </asp:TreeNode>
                
            </asp:TreeNode>
            
            <asp:TreeNode Value="Page 2" 
              Selected="True" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="_blank">
            </asp:TreeNode>
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView> 
       

    </form>
  </body>
</html>

注釈

このプロパティを ExpandImageUrl 使用して、展開可能ノード インジケーターのカスタム イメージを指定します。 この画像は、展開可能なノードの横に表示され、通常はプラス記号 (+) です。

プロパティが ShowExpandCollapse 設定 trueされている場合、 TreeView コントロールは、ノードの横にプラス記号 (+) またはマイナス記号 (-) またはプレースホルダー 画像を表示して、ノードが展開可能か、折りたたみ可能か、または展開不可であるかを示します。 カスタム イメージを指定するには、最初にプロパティをImageSetTreeViewImageSet.Custom設定してから、カスタム イメージの NoExpandImageUrlURL に 、ExpandImageUrlおよびCollapseImageUrlプロパティを設定します。 イメージが指定されていない場合は、既定のイメージが使用されます。 拡張ノード インジケーターを非表示にするには、プロパティfalseShowExpandCollapse .

注意

カスタム イメージを使用するときに、コントロール内でTreeViewノードが正しく配置されるようにするには、プロパティCollapseImageUrlNoExpandImageUrlExpandImageUrl指定されているすべてのイメージが同じディメンションを持っていることを確認します。

カスタム イメージを正しく表示するには、次のように設定ShowLinesfalseする必要があります。

展開可能なノード インジケーターにカスタム イメージを使用する場合は、イメージのツールヒントを ExpandImageToolTip 指定するようにプロパティを設定することも検討する必要があります。

このプロパティの値は、ビューステートに格納されます。

適用対象

こちらもご覧ください