TreeNodeBinding.ImageToolTip 屬性

定義

取得或設定影像的工具提示文字,該影像是顯示在套用 TreeNodeBinding 物件的節點旁。

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

屬性值

String

影像的工具提示文字,該影像是顯示在套用 TreeNodeBinding 物件的節點旁。 預設為空字串 (""),表示未設定 P:System.Web.UI.WebControls.TreeNodeBinding.ImageToolTip 屬性。

範例

本節包含兩個程式碼範例。 第一個程式碼範例示範如何使用 ImageToolTip 屬性來指定套用物件之節點 TreeNodeBinding 旁邊所顯示影像的工具提示文字。 第二個程式碼範例會提供第一個程式碼範例的範例 XML 資料。

下列範例示範如何使用 ImageToolTip 屬性來指定套用物件之節點 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 控制項系結至資料來源時,請使用 ImageToolTip 屬性來指定值以系結至 ImageToolTip 物件的 屬性 TreeNode 。 您指定的文字會為輔助技術裝置提供影像的描述,可用來讓控制項更容易存取。

這個系結關聯性會影響套用物件的所有 TreeNode 物件 TreeNodeBinding 。 當影像顯示在節點旁邊時,當滑鼠指標放在影像上方時,就會顯示工具提示文字。

注意

您可以直接設定 ImageToolTip 每個節點的 屬性,選擇性地覆寫 ImageToolTip 屬性。

您可以藉由設定 ImageToolTipField 屬性,將 物件的 屬性 TreeNode 系結至資料來源的欄位,而不是使用 ImageToolTip 屬性將相同的 ToolTip 文字系結 ImageToolTip 至每個節點影像。

這個屬性的值會儲存在檢視狀態中。

設定時,這個屬性的值可以使用設計工具自動儲存到資源檔。 如需詳細資訊,請參閱 LocalizableAttribute全球化和當地語系化

適用於

另請參閱