TreeNodeBinding.ToolTip Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur teks TipsAlat untuk simpul tempat TreeNodeBinding objek diterapkan.
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
Nilai Properti
Teks TipsAlat untuk simpul tempat TreeNodeBinding objek diterapkan. Defaultnya adalah string kosong (""), yang menunjukkan bahwa ToolTip properti tidak diatur.
Contoh
Bagian ini berisi dua contoh kode. Contoh kode pertama menunjukkan cara menggunakan ToolTip properti untuk menentukan teks TipsAlat untuk simpul tempat TreeNodeBinding objek diterapkan. Contoh kode kedua menyediakan contoh data XML untuk contoh kode pertama.
Contoh berikut menunjukkan cara menggunakan ToolTip properti untuk menentukan teks TipsAlat untuk simpul tempat TreeNodeBinding objek diterapkan. Agar contoh ini berfungsi dengan benar, Anda harus menyalin data XML sampel, yang disediakan setelah contoh kode ini, ke file bernama 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>
Contoh kode berikut menyediakan contoh data XML untuk contoh kode sebelumnya.
<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>
Keterangan
TreeView Saat kontrol terikat ke sumber data, gunakan ToolTip properti untuk menentukan nilai yang akan diikat ke ToolTip properti TreeNode objek. Hubungan pengikatan ini mempengaruhi semua TreeNode objek tempat TreeNodeBinding objek diterapkan. Teks TipsAlat ditampilkan saat penunjuk mouse diposisikan di atas simpul.
Catatan
Anda dapat secara selektif mengambil alih ToolTip properti dengan mengatur ToolTip properti setiap simpul secara langsung.
Alih-alih menggunakan ToolTip properti untuk mengikat teks TipsAlat yang sama ke setiap simpul, Anda bisa mengikat ToolTip properti TreeNode objek ke bidang sumber data dengan mengatur ToolTipField properti .
Nilai properti ini disimpan dalam status tampilan.
Nilai properti ini, ketika diatur, dapat disimpan secara otomatis ke file sumber daya dengan menggunakan alat perancang. Untuk informasi selengkapnya, lihat LocalizableAttribute dan Globalisasi dan Pelokalan.