如何设置提示为ListviewSubItem [英] How to set tooltip for a ListviewSubItem

查看:7753
本文介绍了如何设置提示为ListviewSubItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView控件详细信息视图作为(即显示列表作为网格视图)

I have a ListView control in Details view as that (the view that shows the list as a grid)

    mListView.View = View.Details; 
    mListView.mLVSelectedObject.ShowItemToolTips = true;

    ListViewItem listViewItem = mListView.Items.Add(lValue.Name);
    listViewItem.ToolTipText = "AAAAAAAAAAAAAAAAA";

的问题是,工具提示只显示了当光标是在第一个列表视图的列,但不适合其余Ó他们。我想知道如果有无论如何要使其出现伊斯利?

The issue is that the tooltip only shows up when the cursors is over the first listview's column but not for the rest o them. I want to know if there's anyway to make it appear "easly" ?

推荐答案

经过一番研究。我已经解决了这个样子,但我仍然不知道是否有另一种方式来做到这一点,避免事件处理器;

After some research. I've solved the issue this way, but I'm still wondering if there is another way to do that avoiding EventHandlers;

    ToolTip     mTooltip;
    Point mLastPos = new Point(-1, -1);

    private void listview_MouseMove(object sender, MouseEventArgs e)
    {
        ListViewHitTestInfo info    =   mLV.HitTest(e.X, e.Y);

        if (mTooltip == null)
            mTooltip = new ToolTip();

        if (mLastPos != e.Location)
        {
            if (info.Item != null && info.SubItem != null)
            {
                mTooltip.ToolTipTitle = info.Item.Text;
                mTooltip.Show(info.SubItem.Text, info.Item.ListView, e.X, e.Y, 20000);
            }
            else
            {
                mTooltip.SetToolTip(mLV, string.Empty);
            }
        }

        mLastPos = e.Location;
    }

这篇关于如何设置提示为ListviewSubItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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