TreeNodeBinding.ImageToolTip 属性

定义

获取或设置显示在 TreeNodeBinding 对象应用到的节点旁边的图像的 ToolTip 文本。

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 对象应用到的节点旁边的图像的 ToolTip 文本。 默认值为空字符串 (""),表示未设置 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属性将对象的属性绑定到数据源的字段,而不是使用ImageToolTip属性将同一TreeNode工具提示文本绑定到ImageToolTip每个节点图像。

此属性的值以视图状态存储。

设置时,此属性的值可以使用设计器工具自动保存到资源文件中。 有关详细信息,请参阅LocalizableAttribute全球化和本地化

适用于

另请参阅