TreeNode.ImageToolTip 属性

定义

获取或设置在节点旁边显示的图像的工具提示文本。

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

在节点旁边显示的图像的工具提示文本。 默认值为空字符串 (""),表示尚未设置此属性。

示例

下面的代码示例演示如何使用 ImageToolTip 属性为节点旁边显示的图像指定工具提示文本。 若要使此示例正常工作,必须提供自己的映像。


<%@ 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>TreeNode ImageToolTip Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode ImageToolTip Example</h3>
      
      <h5>Position the mouse pointer over a node image.</h5>
    
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ExpandDepth="2"
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            ImageUrl="~\images\Contents.jpg"
            ImageToolTip="Table of Contents Description">
             
            <asp:TreeNode Text="Chapter One"
               ImageUrl="~\images\Chapter1.jpg"
               ImageToolTip="Chapter One Description">
            
              <asp:TreeNode Text="Section 1.0"
                ImageUrl="~\images\Section1.jpg"
                ImageToolTip="Section 1.0 Description">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1"
                ImageUrl="~\images\Section1_1.jpg"
                ImageToolTip="Section 1.1 Description">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two"
              ImageUrl="~\images\Chapter2.jpg"
              ImageToolTip="Chapter Two Description">
            
              <asp:TreeNode Text="Section 2.0"
                ImageUrl="~\images\Section2.jpg"
                ImageToolTip="Section 2.0 Description">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          
          <asp:TreeNode Text="Appendix A"
            ImageUrl="~\images\AppendixA.jpg" 
            ImageToolTip="Appendix A Description"/>
          <asp:TreeNode Text="Appendix B"
            ImageUrl="~\images\AppendixB.jpg" 
            ImageToolTip="Appendix B Description"/>
          <asp:TreeNode Text="Appendix C"
            ImageUrl="~\images\AppendixC.jpg" 
            ImageToolTip="Appendix C Description"/>
        
        </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>TreeNode ImageToolTip Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNode ImageToolTip Example</h3>
      
      <h5>Position the mouse pointer over a node image.</h5>
    
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ExpandDepth="2"
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            ImageUrl="~\images\Contents.jpg"
            ImageToolTip="Table of Contents Description">
             
            <asp:TreeNode Text="Chapter One"
               ImageUrl="~\images\Chapter1.jpg"
               ImageToolTip="Chapter One Description">
            
              <asp:TreeNode Text="Section 1.0"
                ImageUrl="~\images\Section1.jpg"
                ImageToolTip="Section 1.0 Description">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1"
                ImageUrl="~\images\Section1_1.jpg"
                ImageToolTip="Section 1.1 Description">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two"
              ImageUrl="~\images\Chapter2.jpg"
              ImageToolTip="Chapter Two Description">
            
              <asp:TreeNode Text="Section 2.0"
                ImageUrl="~\images\Section2.jpg"
                ImageToolTip="Section 2.0 Description">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          
          <asp:TreeNode Text="Appendix A"
            ImageUrl="~\images\AppendixA.jpg" 
            ImageToolTip="Appendix A Description"/>
          <asp:TreeNode Text="Appendix B"
            ImageUrl="~\images\AppendixB.jpg" 
            ImageToolTip="Appendix B Description"/>
          <asp:TreeNode Text="Appendix C"
            ImageUrl="~\images\AppendixC.jpg" 
            ImageToolTip="Appendix C Description"/>
        
        </Nodes>
        
      </asp:TreeView>

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

注解

当将属性设置为) 时 ImageUrl ,节点旁边显示图像 (时,请使用 ImageToolTip 该属性指定当用户将鼠标指针放置在图像上时显示的工具提示。 你指定的文本为辅助技术设备提供图像的说明,这些图像可用于使控件更易于访问。

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

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

适用于

另请参阅