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
查看全文
相关阅读:
C# tcp发送十六进制数据
WPF中通过AForge实现USB摄像头拍照
借鉴过的别人的帖子之C#篇
C# 连续的语音识别
C# NAudio 录音
AS3 水波纹
ARM多核心集群服务器
RK3399Pro Android Rock-X 人工智能开发系列(2)
智能化连锁门店解决方案
RK3399Pro Android Rock-X 人工智能开发系列(1)
原文地址:https://www.cnblogs.com/TextEditor/p/1524965.html
最新文章
互联网常用协议及工作端口
http协议
XML案例(使用DOM4J解析XML文档)
XML案例(使用JAXP进行SAX解析)
XML案例(使用JAXP进行DOM解析)
XML Schema
XML约束
高性能mysql第3版pdf 高清中文版下载
半个世纪长盛不衰,SQL为什么如此成功?
java从入门到精通 PDF完整版下载
热门文章
linux 查看磁盘分区的常用指令
关于ORA-3136的处理思路
impdp遭遇ORA-39001、ORA-39000,ORA-39142
ORA-609 错误分析及解决方法
MySQL聚集索引
MySQL从二叉树到B+树
AS3 graphics类中的一些常用函数(转)
C# 读写注册表
Unity中触摸和鼠标操作的几个问题
unity Leap Motion 手势识别
Copyright © 2011-2022 走看看