码迷,mamicode.com
首页 > 其他好文 > 详细

VB ListBox 添加横向滚动条

时间:2014-12-23 15:28:56      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

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 Const LB_SETHORIZONTALEXTENT = &H194
--------------------------------------------------------------------------------------------------
Private Sub setListWidth() 如果列表框不够宽,则增加水平滚动条 Dim i As Integer Dim List_MaxL As Integer 获得选项内容的最大长度 For i = 0 To List1.ListCount - 1 '让list_maxl中保存最长的一条字串 If Len(List1.List(i)) > List_MaxL Then List_MaxL = Len(List1.List(i)) + 2 End If Next i 判断是否内容显示不完全,如果是则添加水平滚动条 If Me.TextWidth("AA ") * List_MaxL > List1.Width Then SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, Me.TextWidth("a") * List_MaxL, ByVal 0& End If End Sub
--------------------------------------------------------------------------------------------------
Private Sub Form_Load()
      Dim i     As Integer
      为ListBox控件添加选项
      For i = 0 To 100
            List1.AddItem ("这是,最据jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj:(第   " + CStr(i)) & "行) "
           List1.AddItem   ( "(第   "   +   CStr(i))   &   "行) "
      Next i
      设置窗体坐标尺度模式和字体大小
      Me.ScaleMode = vbPixels
      Me.FontSize = List1.FontSize
     设置列表框的水平滚动条
      Call setListWidth
End Sub

 

VB ListBox 添加横向滚动条

标签:

原文地址:http://www.cnblogs.com/wx881208/p/4180035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!