标题:Excel中combox可以设置listwidth,VB6中combo怎么设置?
只看楼主
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:14 
程序代码:
Option Explicit

Private Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
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 CB_GETITEMHEIGHT = &H154

Private Sub Combo1_GotFocus()
    SetComboHeight Combo1, 50
End Sub

Private Sub Form_Load()
    Dim i&
    For i = 0 To 333
        Combo1.AddItem i
    Next
End Sub

Private Sub SetComboHeight(cboNegPressureList As ComboBox, ByVal nListCount As Long)
Dim ListHeight As Long
With cboNegPressureList
    ListHeight = SendMessage(.hWnd, CB_GETITEMHEIGHT, 0,byval 0&)
    MoveWindow .hWnd, Me.ScaleX(.Left, Me.ScaleMode, vbPixels), Me.ScaleY(.Top, Me.ScaleMode, vbPixels), Me.ScaleX(.Width, Me.ScaleMode, vbPixels), ListHeight * nListCount, 1
End With
End Sub
2010-03-22 13:07
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
得分:0 
回复 11楼 bczgvip
我要的是Width,显示行的宽度 你的代码是Height,可以帮忙修改下吗?

[ 本帖最后由 yuk_yu 于 2010-3-22 14:20 编辑 ]
2010-03-22 13:57
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:0 
= =;
那么,你那图是什么意思?不是显示出来了吗?不是已经改变宽度了吗?
2010-03-22 14:21
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
得分:0 
回复 13楼 bczgvip
我是在Excel中用做的,Excel中可以直接设置listwidth.
2010-03-22 15:23
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:0 

我去跳楼算了。
说来说去都是牛头不对马嘴。
2010-03-22 18:25
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
得分:0 
回复 15楼 bczgvip
对不起,是我让你困惑了,因为在EXCEL中很容易就能设置listwidth,但在VB6中好象没有现成的属性设置项,还是请大家帮帮忙!谢谢
2010-03-23 09:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-299820-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.224363 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved