How to increase AutoPopDelay value for ListViewItems in WinForms?

后端 未结 3 1527
故里飘歌
故里飘歌 2021-01-23 01:22

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 displa

3条回答
  •  逝去的感伤
    2021-01-23 02:19

    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.

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

    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;
    

提交回复
热议问题