TreeNodeBinding.ImageUrl プロパティ

定義

TreeNodeBinding オブジェクトが適用されるノードの横に表示されるイメージの URL を取得または設定します。

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

プロパティ値

String

TreeNodeBinding オブジェクトが適用されるノードの横に表示されるイメージの URL。 次に、 ImageUrl プロパティが設定されていません。

このセクションには、2 つのコード例が含まれています。 最初のコード例では、プロパティを使用して特定の Depth ノードの深さでオブジェクトを TreeNodeBinding 適用する方法を示します。 2 番目のコード例では、最初のコード例のサンプル XML データを提供します。

次のコード例は、プロパティを使用して、オブジェクトが ImageUrl 適用されるノードのカスタム イメージを指定する方法を TreeNodeBinding 示しています。 この例を正しく動作させるには、このコード例の後に提供されるサンプル XML データを、Booklist.xmlという名前のファイルにコピーする必要があります。


<%@ 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>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the Text, ImageUrl, ImageToolTip, -->
      <!-- NavigateUrl, Value, and ToolTip       -->
      <!-- properties of a TreeNodeBinding       -->
      <!-- object declaratively.                 -->   
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            Text="Book Title" 
            ImageUrl="Image.jpg"
            ImageToolTip="Book Image" 
            NavigateUrl="http://www.microsoft.com" 
            Value="BookID" 
            ToolTip="Book Information"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </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>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the Text, ImageUrl, ImageToolTip, -->
      <!-- NavigateUrl, Value, and ToolTip       -->
      <!-- properties of a TreeNodeBinding       -->
      <!-- object declaratively.                 -->   
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            Text="Book Title" 
            ImageUrl="Image.jpg"
            ImageToolTip="Book Image" 
            NavigateUrl="http://www.microsoft.com" 
            Value="BookID" 
            ToolTip="Book Information"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

次のコード例では、前の例のサンプル XML データを提供します。

<Books Text="Books List">  
    <Book Text="Book Title One"  
        Value="1"   
        Image="Bookimage1.jpg"  
        ImageToolTip="Book 1 Photo"   
        Nav="http://www.microsoft.com"  
        Tip="Book Title 1">  
        <Description Text="Book Description">  
        </Description>  
        <Price Value="$1.99">  
        </Price>  
        <Author Text="Author Name"  
            Value="LastName"   
            Image="Authorimage1.jpg"   
            Nav="http://www.microsoft.com"  
            Tip="Author Name">  
        </Author>  
    </Book>  
    <Book Text="Book Title Two"  
        Value="2"   
        Image="Bookimage2.jpg"  
        ImageToolTip="Book 2 Photo"   
        Nav="http://www.microsoft.com"  
        Tip="Click Me">  
        <Description Text="Book Description">  
        </Description>  
        <Price Value="$2.99">  
        </Price>  
        <Author Text="Author Name"  
            Value="LastName"   
            Image="Authorimage2.jpg"   
            Nav="http://www.microsoft.com"  
            Tip="Author Name">  
        </Author>  
    </Book>  
</Books>  

注釈

コントロールがTreeViewデータ ソースにバインドされている場合は、プロパティをImageUrl使用して、オブジェクトのプロパティにバインドするカスタム イメージをImageUrlTreeNode指定します。 このバインド関係は、オブジェクトが適用されるすべての TreeNode オブジェクトに TreeNodeBinding 影響します。 イメージはノードの横に表示され、クライアント ブラウザーがその形式をサポートしている限り、任意のファイル形式 (.jpg、.gif、.bmpなど) にすることができます。

注意

個々のノードのイメージをオーバーライドするには、そのプロパティを ImageUrl 直接設定します。

このプロパティを使用して各ノードに同じイメージをバインドする代わりに、プロパティを ImageUrl 設定することで、オブジェクトの TreeNode プロパティをデータ ソースのフィールドに ImageUrlField バインドできます。

プロパティを持つノードの横にイメージを ImageUrl 表示する場合は、プロパティの設定も検討する ImageToolTip 必要があります。 指定したツールヒント テキストは、コントロールのアクセシビリティを高めるために使用できるイメージの説明を支援技術デバイスに提供します。

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

適用対象

こちらもご覧ください