zoukankan
html css js c++ java
带有ToolTip的ListBox
Code
1
Private
Sub ListBox1_MouseMove()
Sub
ListBox1_MouseMove(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.Forms.MouseEventArgs)
Handles
ListBox1.MouseMove
2
Dim
MousePositionInClientCoords
As
Point
=
Me
.ListBox1.PointToClient(
Me
.MousePosition)
3
Dim
indexUnderTheMouse
As
Integer
=
Me
.ListBox1.IndexFromPoint(MousePositionInClientCoords)
4
If
indexUnderTheMouse
>
-
1
Then
5
Dim
s
As
String
=
Me
.ListBox1.Items(indexUnderTheMouse).ToString
6
Dim
g
As
Graphics
=
Me
.ListBox1.CreateGraphics
7
If
g.MeasureString(s,
Me
.ListBox1.Font).Width
>
Me
.ListBox1.ClientRectangle.Width
Then
8
Me
.ToolTip1.SetToolTip(
Me
.ListBox1, s)
9
Else
10
Me
.ToolTip1.SetToolTip(
Me
.ListBox1,
""
)
11
End
If
12
g.Dispose()
13
End
If
14
End Sub
15
或者
Code
1
Private
Sub ListBox1_MouseMove()
Sub
ListBox1_MouseMove(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.Forms.MouseEventArgs)
Handles
ListBox1.MouseMove
2
Dim
MousePositionInClientCoords
As
Point
=
New
Point(e.X, e.Y)
3
Dim
indexUnderTheMouse
As
Integer
=
Me
.ListBox1.IndexFromPoint(MousePositionInClientCoords)
4
If
indexUnderTheMouse
>
-
1
Then
5
Dim
s
As
String
=
Me
.ListBox1.Items(indexUnderTheMouse).ToString
6
Dim
g
As
Graphics
=
Me
.ListBox1.CreateGraphics
7
If
g.MeasureString(s,
Me
.ListBox1.Font).Width
>
Me
.ListBox1.ClientRectangle.Width
Then
8
Me
.ToolTip1.SetToolTip(
Me
.ListBox1, s)
9
Else
10
Me
.ToolTip1.SetToolTip(
Me
.ListBox1,
""
)
11
End
If
12
g.Dispose()
13
End
If
14
End Sub
查看全文
相关阅读:
按属性分割要素
python os.path模块
用数组显示裴波那契数列
计算两位数的加减乘除
输入一串数字统计0到9每个数字的个数
开辟新空间输入成绩
关系表达式、条件表达式、逻辑表达式
变量、函数和程序控制
哥德巴赫定理
找出二维数组中最大的值
原文地址:https://www.cnblogs.com/TextEditor/p/1524965.html
最新文章
小项目之网络电视精灵
高级SQL运用
存储过程
常用的系统存储过程
[LeetCode No.327] 区间和个数
通俗易懂Apriori算法及Python实现
OrderedDict实现FIFODict
深入理解intern()
String.intern()初探
阿里云服务器配置Tip
热门文章
第一个SSM完整项目开发心得
SSM框架Kaptcha验证码的使用
自我学习SSM框架集成(三)
自我学习SSM框架集成(二)
三种方法加载MXD文档 (LoadMxFile方法和IMapDocument方法和IMapDocument方法)
界面设计
vs常用快捷键
python os.path模块常用方法详解
python之模块之shutil模块
脚本中shp文件在arcgis10.1下可以访问。在10.3下貌似不行
Copyright © 2011-2022 走看看