TreeNodeBinding.ToolTip 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 TreeNodeBinding 对象应用到的节点的 ToolTip 文本。
public:
property System::String ^ ToolTip { System::String ^ get(); void set(System::String ^ value); };
public string ToolTip { get; set; }
member this.ToolTip : string with get, set
Public Property ToolTip As String
属性值
TreeNodeBinding 对象应用到的节点的 ToolTip 文本。 默认值为空字符串 (""),表示尚未设置 ToolTip 属性。
示例
本部分包含两个代码示例。 第一个代码示例演示如何使用 ToolTip 属性为应用对象的节点 TreeNodeBinding 指定工具提示文本。 第二个代码示例为第一个代码示例提供示例 XML 数据。
以下示例演示如何使用 ToolTip 属性为应用对象的节点 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 控件绑定到数据源时,请使用 ToolTip 该属性指定要绑定到 ToolTip 对象的属性 TreeNode 的值。 此绑定关系会影响应用对象的所有 TreeNode 对象 TreeNodeBinding 。 当鼠标指针放置在节点上时,将显示工具提示文本。
通过设置ToolTipField属性,可以将对象的属性绑定到数据源的字段,而不是使用ToolTip属性将同一TreeNode工具提示文本绑定到ToolTip每个节点。
此属性的值存储在视图状态中。
设置时,此属性的值可以使用设计器工具自动保存到资源文件中。 有关详细信息,请参阅LocalizableAttribute全球化和本地化。