如何增加WinForms中ListViewItems的AutoPopDelay值? [英] How to increase AutoPopDelay value for ListViewItems in WinForms?

查看:81
本文介绍了如何增加WinForms中ListViewItems的AutoPopDelay值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道ListView中的每个项目都有一个ToolTipText属性,仅此而已!没有像AutoPopDelay这样的属性来设置其显示时间...始终为默认值5000 ms.我试图将ToolTip与每个项目相关联,但这似乎是不可能的.

You know that each item in a ListView has a ToolTipText property and that's all! There is no property like AutoPopDelay to set its display time... Always the default value, 5000 ms. I tried to associate a ToolTip to each item, but it seems to be impossible.

反正有没有增加ListViewItemToolTipText属性的显示时间?

Is there anyway to increase the display time for ToolTipText property of a ListViewItem?

推荐答案

您可以使用

You can get the ToolTip of the ListView using LVM_GETTOOLTIPS, then send a TTM_SETDELAYTIME message to the tooltip and set its delay by passing TTDT_AUTOPOP as wparam and the delay in millisecond as lparam.

还要确保将ListViewShowItemsToolTip属性设置为true,并且项目具有工具提示.

Also make sure ShowItemsToolTip property of the ListView has been set to true and the items have tooltip.

[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
const int LVM_GETTOOLTIPS = 0x104E;
const int TTM_SETDELAYTIME = 0x403;
const int TTDT_AUTOPOP = 2;

private void button1_Click(object sender, EventArgs e)
{
    var tooltip = SendMessage(listView1.Handle, LVM_GETTOOLTIPS, 0, 0);
    SendMessage(tooltip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 10000 /*milliseconds*/);
}

要设置初始延迟或重新显示延迟,请为wparam设置以下值:

To set the initial delay or the reshow delay, set the following values for wparam:

const int TTDT_AUTOMATIC = 0;
const int TTDT_AUTOPOP = 2;
const int TTDT_INITIAL = 3;

这篇关于如何增加WinForms中ListViewItems的AutoPopDelay值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆