ListView.ShowItemToolTips 屬性

定義

取得或設定值,指示是否為包含於 ListViewItem 中的 ListView 物件顯示工具提示。

public:
 property bool ShowItemToolTips { bool get(); void set(bool value); };
public bool ShowItemToolTips { get; set; }
member this.ShowItemToolTips : bool with get, set
Public Property ShowItemToolTips As Boolean

屬性值

如果應該要顯示 ListViewItem 工具提示,則為 true,否則為 false。 預設為 true

範例

下列程式碼範例示範如何使用 ShowItemToolTipsListViewItem.ToolTipText 屬性。 若要執行此範例,請將程式碼貼到 Windows Form,並從表單的建構函式或 Load 事件處理常式呼叫 InitializeItemsWithToolTips


// Declare the ListView.
private ListView ListViewWithToolTips;
private void InitializeItemsWithToolTips()
{

    // Construct and set the View property of the ListView.
    ListViewWithToolTips = new ListView();
    ListViewWithToolTips.Width = 200;
    ListViewWithToolTips.View = View.List;

    // Show item tooltips.
    ListViewWithToolTips.ShowItemToolTips = true;
    
    // Create items with a tooltip.
    ListViewItem item1WithToolTip = new ListViewItem("Item with a tooltip");
    item1WithToolTip.ToolTipText = "This is the item tooltip.";
    ListViewItem item2WithToolTip = new ListViewItem("Second item with a tooltip");
    item2WithToolTip.ToolTipText = "A different tooltip for this item.";

    // Create an item without a tooltip.
    ListViewItem itemWithoutToolTip = new ListViewItem("Item without tooltip.");

    // Add the items to the ListView.
    ListViewWithToolTips.Items.AddRange(new ListViewItem[]{item1WithToolTip, 
        item2WithToolTip, itemWithoutToolTip} );

    // Add the ListView to the form.
    this.Controls.Add(ListViewWithToolTips);
    this.Controls.Add(button1);
}
' Declare the ListView.
Private ListViewWithToolTips As ListView

Private Sub InitializeItemsWithToolTips() 
    
    ' Construct and set the View property of the ListView.
    ListViewWithToolTips = New ListView()
    ListViewWithToolTips.Width = 200
    ListViewWithToolTips.View = View.List
    
    ' Show item tooltips.
    ListViewWithToolTips.ShowItemToolTips = True
    
    ' Create items with a tooltip.
    Dim item1WithToolTip As New ListViewItem("Item with a tooltip")
    item1WithToolTip.ToolTipText = "This is the item tooltip."
    Dim item2WithToolTip As New ListViewItem("Second item with a tooltip")
    item2WithToolTip.ToolTipText = "A different tooltip for this item."
    
    ' Create an item without a tooltip.
    Dim itemWithoutToolTip As New ListViewItem("Item without tooltip.")
    
    ' Add the items to the ListView.
    ListViewWithToolTips.Items.AddRange(New ListViewItem() _
        {item1WithToolTip, item2WithToolTip, itemWithoutToolTip})
    
    ' Add the ListView to the form.
    Me.Controls.Add(ListViewWithToolTips)
    Me.Controls.Add(button1)

End Sub

備註

ShowItemToolTips如果 屬性設定 true 為 ,則具有工具提示的任何 ListViewItem 專案都會顯示它,否則不會顯示任何內容。

適用於