用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧VisualBasic

在ListBox适当设定水平滚动条的宽度

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 19:49:16
Option Explicit
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub Command1_Click()
Dim max As Long, f As Font, i As Integer

Me.ScaleMode = vbPixels
Set f = Me.Font
Set Me.Font = List1.Font

With List1
For i = 0 To .ListCount
If Me.TextWidth(.List(i)) > max Then
max = Me.TextWidth(.List(i))
End If
Next
End With
max = max + 10

Set Me.Font = f

SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, max, ByVal 0&
End Sub

Private Sub Form_Load()
List1.AddItem "VB编程乐园"
List1.AddItem "http://vbboshi.126.com"
List1.AddItem "这是一个特别特别长的选项,长到超过ListBox的范围"
End Sub

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:16,437.50000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号