| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1846 人关注过本帖
标题:Excel中combox可以设置listwidth,VB6中combo怎么设置?
取消只看楼主 加入收藏
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
结帖率:85.71%
收藏
已结贴  问题点数:20 回复次数:8 
Excel中combox可以设置listwidth,VB6中combo怎么设置?
Excel中combox可以设置listwidth,VB6中combo怎么设置?谢谢大家
搜索更多相关主题的帖子: listwidth Excel combo 
2010-03-18 17:44
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 2楼 wei855198
谢谢,我要的不是加入item,而是加入的数据字符太长,显示不完整,怎么设置宽度!
2010-03-18 18:33
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 4楼 wei855198
我实在太菜了,可以告诉我这个涵数怎么用吗? SetComboWidth ((4))为何提示类型不匹配?

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 Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Sub SetComboWidth(cboIn As ComboBox)
    ' Resize the with of the dropdown portion of a combobox to accomodate the longest item
     
     Dim nCount As Long
     Dim nNumChars As Long
     Dim nLongestComboItem As Long
     Dim nNewDropDownWidth As Long
     Dim nOldScaleMode As Integer
     Dim nLongestComboItemIndex As Integer
     Dim oOldFont As Font
     
     ' Loop through the cboIn entries, to determine the longest item
     For nCount = 0 To cboIn.ListCount - 1
     nNumChars = SendMessage(cboIn.hwnd, CB_GETLBTEXTLEN, nCount, CLng(0))
     If nNumChars > nLongestComboItem Then
     nLongestComboItem = nNumChars
     nLongestComboItemIndex = nCount
     End If
     Next
     
     ' Save the parent's font and scale mode
     nOldScaleMode = cboIn.Parent.ScaleMode
     Set oOldFont = cboIn.Parent.Font
     
     cboIn.Parent.ScaleMode = vbPixels
     Set cboIn.Parent.Font = cboIn.Font
     
     ' Get Width of longest item in pixels
     nNewDropDownWidth = cboIn.Parent.TextWidth(cboIn.List(nLongestComboItemIndex))
     cboIn.Parent.ScaleMode = nOldScaleMode
     Set cboIn.Parent.Font = oOldFont
     
     ' Add width of vertical scrollbar
     If cboIn.ListCount > 8 Then
     nNewDropDownWidth = nNewDropDownWidth + GetSystemMetrics(SM_CYVSCROLL) + 7
     Else
     nNewDropDownWidth = nNewDropDownWidth + 7
     End If
     ' Resize the dropdown portion of the cboIn box
     SendMessage cboIn.hwnd, CB_SETDROPPEDWIDTH, nNewDropDownWidth, CLng(0)
    End Sub

[ 本帖最后由 yuk_yu 于 2010-3-19 12:03 编辑 ]
2010-03-19 09:10
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 5楼 yuk_yu
期待大家指点指点!
2010-03-19 21:59
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 7楼 bczgvip
版主,如果我有个combo1(i)数组,怎样才能实现将我要显示的内容显示全?谢谢
2010-03-20 10:08
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 9楼 bczgvip
conbo.rar (1.87 KB)
见附件
2010-03-22 09:14
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
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 13楼 bczgvip
我是在Excel中用做的,Excel中可以直接设置listwidth.
2010-03-22 15:23
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 15楼 bczgvip
对不起,是我让你困惑了,因为在EXCEL中很容易就能设置listwidth,但在VB6中好象没有现成的属性设置项,还是请大家帮帮忙!谢谢
2010-03-23 09:24
快速回复:Excel中combox可以设置listwidth,VB6中combo怎么设置?
数据加载中...
 
   



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

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