在此只能回答第二个问题
VBControlExtender用于运行时添加的控件的引用,就是说不在VB工具箱内的控件。先用Lisences集合注册控件,然后就可以在Controls集合添加这个设计时不存在的控件。由于不知道具体的类,所以只能用VBControlExtender来接受对象的引用。当然,内部控件是不可能“不在VB的工具箱里”的,所以不能用于VBControlExtender

解决方案 »

  1.   

    在加一句:
    cmbDropList. style =2
      

  2.   

    fsb_12345
    ComboBox的Style属性在运行时是不可以修改的
      

  3.   

    用GetWindowLong,SetWindowLong改变其属性为何不可用?
      

  4.   

    是不是Controls.Add时可以包括属性了?
      

  5.   

    用API函数可以解决问题Private Const GWL_STYLE = (-16)
    Private Const GW_CHILD = 5Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As LongConst SW_HIDE = 0
    Const SW_SHOW = 5Dim WithEvents cmbDropList As ComboBoxPrivate Sub cmbDropList_Click()
      MsgBox cmbDropList.Text
    End SubPrivate Sub Command1_Click()
      Dim ChildHwnd As Long
      
      Set cmbDropList = Controls.Add("VB.ComboBox", "cmbDropList")
      
      cmbDropList.Visible = True
      cmbDropList.AddItem "One"
      cmbDropList.AddItem "Two"
      
      ChildHwnd = GetWindow(cmbDropList.hwnd, GW_CHILD)   '取edit句柄
      Call DestroyWindow(ChildHwnd)                       'Kill edit窗口
      '改变cmbDropList的Style,这一语句可有可无~~~~,
      Call SetWindowLong(cmbDropList.hwnd, GWL_STYLE, GetWindowLong(cmbDropList.hwnd, GWL_STYLE) + 1)End Sub