关于listbox的问题,急急

jourmen IBM 架构师  2003-12-03 11:00:19
bv里怎样在listbox里,当显示的信息大于listbox显示面积的时候,出现水平滚动条
垂直滚动条他自己就可以出现,水平的呢?

如果没有水平滚动条属性,如何将和水平滚动条绑定?
...全文
4 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
海牛 2003-12-03
同意楼上的。
回复
TechnoFantasy 2003-12-03
Option Explicit

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 Command1_Click()
List1.AddItem "Line 1"
List1.AddItem "a big Line 2 some text some text"
List1.AddItem "Line 3"
addHorScrlBarListBox List1
End Sub

Public Sub addHorScrlBarListBox(ByVal refControlListBox As Object)
' 加横向滚动条

Dim nRet As Long
Dim nNewWidth As Integer

nNewWidth = refControlListBox.Width + 100 ' 新宽度,以像素为单位。
nRet = SendMessage(refControlListBox.hwnd, _
LB_SETHORIZONTALEXTENT, nNewWidth, ByVal 0&)
End Sub
回复
online 2003-12-03
给listbox添加水平滚动条??
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 Demo_LBox_GotFocus()
Dim i As Integer
Dim List_MaxL As Integer

' 获得选项内容的最大长度
For i = 0 To Demo_LBox.ListCount - 1
If Len(Demo_LBox.List(i)) > List_MaxL Then
List_MaxL = Len(Demo_LBox.List(i))
End If
Next i

' 判断是否内容显示不完全,如果是则添加水平滚动条
If Me.TextWidth("x") * List_MaxL > Demo_LBox.Width Then
SendMessage Demo_LBox.hwnd, LB_SETHORIZONTALEXTENT, Me.TextWidth("x") * List_MaxL, ByVal 0&
End If
End Sub

Private Sub Form_Load()
Dim i As Integer

' 为ListBox控件添加选项
For i = 0 To 10
Demo_LBox.AddItem ("This is long item " + CStr(i))
Next i

' 设置窗体坐标尺度模式和字体大小
Me.ScaleMode = vbPixels
Me.FontSize = Demo_LBox.FontSize
End Sub
回复
mybabyhongru 2003-12-03
你用LISTVIEW控件不就可以吗
ListView1.FlatScrollBar = False
ListView1.FullRowSelect = True
回复
发动态
发帖子
控件
创建于2007-09-28

1422

社区成员

VB 控件
申请成为版主
社区公告
暂无公告