我的做法是,因为已经有了一个按钮,所以我干脆做一个list而不是combo,思路是当我按下这个按钮时,在这个cell的左下角开始,显示这个listPrivate Sub dgRecord_ButtonClick(ByVal ColIndex As Integer)
    ' Assign the Column object to Co because it will be used
    ' more than once.
    Dim Co As Column
    
    If ColIndex = -1 Then
        Exit Sub
    End If
    
    Set Co = dgRecord.Columns(ColIndex)
    
    ' Position and drop down List1 at the right edge of the
    ' current cell.
    If Co.Caption = "colName" Then
        With lstOrder
        .Left = dgRecord.Left + Co.Left '+ Co.Width
        .Top = dgRecord.Top + dgRecord.RowTop(dgRecord.Row) + dgRecord.RowHeight    '(dgRecord.Row)
        .Width = Co.Width
        .Visible = True
        .ZOrder 0
        .SetFocus
        End With
    End If
End SubPrivate Sub dgRecord_Scroll(Cancel As Integer)
    ' Hide the list if we scroll.
    lstOrder.Visible = False
End Sub
Private Sub lstOrder_Click()
    ' When an item is selected in lstOrder, copy its index to the
    ' proper column in dgRecord, then make lstOrder invisible.
    dgRecord.Columns("colName").Text = lstOrder.Text               'lstOrder.ItemData(lstOrder.ListIndex + 1)
    lstOrder.Visible = FalseEnd Sub

解决方案 »

  1.   

    datagrid本身有一个属性是可以控制某一列显示combo1列的。
    你可以看一下。同时如果不适用的话可以模仿上位朋友。
    不过如果这样的话,建议使用mshflexgrid控件。
      

  2.   

    楼上的第兄不能那么累吧!
    我有个办法 你看可不可以!
    DataGrid1.Columns(0).Button = True 用 DataGrid1.Columns(Index).Button 属性可以设某一列有按钮.之后再用 DataGrid1 的 ButtonClick 事件捕捉就可以了!你可以算出单元格的位置再把 Combo 现示出来就行了!
      

  3.   

    楼顶的朋友,listbox框不可超出窗体,你可有注意到。
    用combobox,不可调高度,还有不可调边框,很难看。
    用form2.0中的combobox又会被grid复盖,不会显示,我想到用picure1包含combobox,但又有问题,问题是combobox的选择部分是因定宽度,随你怎么改变
    width属性也没用,用sendmessage,又无法得到combobox的hwnd.