Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set tooltip for a ListviewSubItem

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" ?

like image 888
Osk Avatar asked Oct 25 '12 12:10

Osk


1 Answers

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;
    }
like image 152
Osk Avatar answered Sep 17 '22 19:09

Osk