You mention button, the combobox...
Anyways, this uses a FlexGrid not DataGrid, but the theory's about the same...
VB Code:
'cboCell is the name of the combo box and msfCarlines is the name of the MSFlexGrid
'Put SetUpCombo In the Grids Click Event
Dim i As Integer
' Prepare combo
With cboCell
' Hide combo
.Visible = False
.AddItem "line 1"
.AddItem "line 2"
.AddItem "line 3"
End With
' Prepare grid
With msfCarlines
.Top = 0
.Width = Me.Width
.Height = Me.Height
.Left = 0
For i = 0 To msfCarlines.Cols - 1
.RowHeight(i) = cboCell.Height
Next i
End With
Private Sub SetupCombo()
' Setup the combobox by positioning and sizing it over the
' current flexgrid cell
Dim sngL As Single
Dim sngT As Single
Dim sngW As Single
Dim sngH As Single
With msfCarlines.Container
sngL = .ScaleX(msfCarlines.CellLeft, vbTwips, .ScaleMode)
sngT = .ScaleY(msfCarlines.CellTop, vbTwips, .ScaleMode)
sngW = .ScaleX(msfCarlines.CellWidth, vbTwips, .ScaleMode)
sngH = .ScaleY(msfCarlines.CellHeight, vbTwips, .ScaleMode)
End With
With cboCell
.Move msfCarlines.Left + sngL, msfCarlines.Top + sngT, sngW
.Visible = True
.SetFocus
End With
End Sub