ListView.ShowItemToolTips 属性

定义

获取或设置一个值,该值指示是否为 ListViewItem 中包含的 ListView 对象显示工具提示。

C#
public bool ShowItemToolTips { get; set; }

属性值

如果应显示 ListViewItem 工具提示,则为 true;否则为 false。 默认值为 true

示例

下面的代码示例演示如何使用 ShowItemToolTipsListViewItem.ToolTipText 属性。 若要运行此示例,请将代码粘贴到 Windows 窗体中,并从窗体的构造函数或Load事件处理程序调用 InitializeItemsWithToolTips

C#

// 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);
}

注解

如果 属性 ShowItemToolTips 设置为 true,则任何 ListViewItem 具有工具提示的 都将显示该属性;否则不显示任何内容。

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10