[Listview]查看鼠标悬停时的子项内容 [英] [Listview] View subitem content on mouse hover
本文介绍了[Listview]查看鼠标悬停时的子项内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在鼠标悬停在其上时查看子项内容?我有搜索,他们使用工具提示查看listview mousemove上的子项目但没有显示。我的一些数据太长,超出了我的列宽。所以我想通过将鼠标悬停在数据上来预览数据。以下是我尝试但没有运气。
Hi,
How to view a subitem content when hover mouse on it? I have search and they using tooltip to view the subitem on listview mousemove but nothing show up. Some of my data too long which exceed my column width. So I want to preview the data by hovering mouse on it. Below are what I have tried but no luck.
Private Sub lvinfo_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles lvinfo.MouseMove
Dim LVHit As ListViewHitTestInfo
Dim ToolTipText As String = ""
Dim CurrentPosition As Integer = 0
Dim LastBreakpoint As Integer = 0
Dim ToolTipLengthPerLine As Integer = 40
Try
LVHit = lvinfo.HitTest(e.X, e.Y)
If LVHit IsNot Nothing Then
If LVHit.SubItem IsNot Nothing Then
ToolTipText = LVHit.SubItem.Text
While CurrentPosition + ToolTipLengthPerLine < ToolTipText.Length
LastBreakpoint = ToolTipText.Substring(CurrentPosition, ToolTipLengthPerLine).LastIndexOf(" ")
ToolTipText = ToolTipText.Insert(CurrentPosition + LastBreakpoint + 1, vbCrLf)
CurrentPosition += LastBreakpoint + 3
End While
End If
End If
mytip.SetToolTip(lvinfo, ToolTipText)
Catch ex As Exception
strInfoMsg = "Oops! Something is wrong at mouse move." & vbCrLf & "Ex:-" & ex.Message
MessageBox.Show(strInfoMsg, "Error Message!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
推荐答案
看到这个答案: http:/ /stackoverflow.com/questions/11839323/c-show-tooltip-on-subitem [ ^ ]。
/ ravi
See this SO answer: http://stackoverflow.com/questions/11839323/c-show-tooltip-on-subitem[^].
/ravi
这篇关于[Listview]查看鼠标悬停时的子项内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文