如果ComboBox里面的数据的长度比ComboBox本身的长度大的话,有没有办法让ComboBox里的数据全部表示出来,是在ComboBox的列表框里面全部表示出来,就像Microsoft Forms 2.0 Object Library里面的ComboBox一样。

解决方案 »

  1.   

    用windows API,中的sendmessage应该可以。
      

  2.   

    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' Resize a ComboBox's dropdown display area.
    Public Sub SizeCombo(frm As Form, cbo As ComboBox)
    Dim cbo_left As Integer
    Dim cbo_top As Integer
    Dim cbo_width As Integer
    Dim cbo_height As Integer
    Dim old_scale_mode As Integer    ' Change the Scale Mode on the form to Pixels.
        old_scale_mode = frm.ScaleMode
        frm.ScaleMode = vbPixels    ' Save the ComboBox's Left, Top, and Width values.
        cbo_left = cbo.Left
        cbo_top = cbo.Top
        cbo_width = cbo.Width    ' Calculate the new height of the combo box.
        cbo_height = frm.ScaleHeight - cbo.Top - 5
        frm.ScaleMode = old_scale_mode    ' Resize the combo box window.
        MoveWindow cbo.hwnd, cbo_left, cbo_top, cbo_width, cbo_height, 1End Sub
    用这个代码可以改变ComboBox中下拉菜单的高度。你就可以自己设置高度让所有的项目显示出来了。
      

  3.   

    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 Sub Form_Load()
        Me.ScaleMode = vbPixels
        MoveWindow Combo1.hwnd, Combo1.Left, Combo1.Top, Combo1.Width, ScaleHeight - Combo1.Top, 1End Sub