How to set tooltips on ListView Subitems in .Net

后端 未结 5 1264
轻奢々
轻奢々 2021-02-10 09:15

I am trying to set the tool tip text for some of my subitems in my listview control. I am unable to get the tool tip to show up.

Anyone have any suggestions?

         


        
5条回答
  •  抹茶落季
    2021-02-10 09:28

    You can use the MouseMove event:

    private void listview1_MouseMove(object sender, MouseEventargs e)
    {
        ListViewItem item = listview1.GetItemAt(e.X, e.Y);
        ListViewHitTestInfo info = listview1.HitTest(e.X, e.Y);
        if((item != null) && (info.SubItem != null))
        {
            toolTip1.SetToolTip(listview1, info.SubItem.Text);
        }
        else
        {
            toolTip1.SetToolTip(listview1, "");
        }
    }
    

提交回复
热议问题