I'm not using a combobox, i'm using number boxes in my grid so somebody doesn't enter letters. I have done the same thing only with a combobox before. All you need to do is replace TDBQtyPacked with you combobox name. If you need anymore help please let me know. I hope this helps, its not the best way, but its better than spending the money on third party controls.
here is my code:
Private Sub dgPacking_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgPacking.MouseUp
'Get size and location of grid cell
Dim cb As New System.Drawing.Rectangle 'cell bounds
Dim cb2 As New System.Drawing.Rectangle
If dgPacking.CurrentCell.ColumnNumber = 3 And dgPacking.CurrentCell.RowNumber = dgPacking.CurrentRowIndex Then
'TDBDQtyPacked.Visible = True
If Not TDBDQtyPacked.Tag = "Open" Then
cb = dgPacking.GetCellBounds(dgPacking.CurrentRowIndex, 3)
TDBDQtyPacked.Location = New Point(cb.X, cb.Y)
TDBDQtyPacked.Size = New Size(cb.Width, cb.Height)
TDBDQtyPacked.Value = dgPacking.Item(dgPacking.CurrentRowIndex, 3)
dgPacking.Controls.Add(TDBDQtyPacked)
'TDBDQtyPacked.BringToFront()
'Must Add the events you want to use
AddHandler TDBDQtyPacked.Change, AddressOf TDBDQtyPacked_Change
Else
' 'Same as above "With out Addhandler if control is already open"
cb = dgPacking.GetCellBounds(dgPacking.CurrentRowIndex, 3)
TDBDQtyPacked.Location = New Point(cb.X, cb.Y)
TDBDQtyPacked.Size = New Size(cb.Width, cb.Height)
TDBDQtyPacked.Value = dgPacking.Item(dgPacking.CurrentRowIndex, 3)
dgPacking.Controls.Add(dgNumbox)
End If
TDBDQtyPacked.Visible = True
End If
If dgPacking.CurrentCell.ColumnNumber = 2 And dgPacking.CurrentCell.RowNumber = dgPacking.CurrentRowIndex Then
If Not TDBTimeEach.Tag = "Open" Then
cb2 = dgPacking.GetCellBounds(dgPacking.CurrentRowIndex, 2)
TDBTimeEach.Location = New Point(cb2.X, cb2.Y)
TDBTimeEach.Size = New Size(cb2.Width, cb2.Height)
TDBTimeEach.Value = dgPacking.Item(dgPacking.CurrentRowIndex, 2)
dgPacking.Controls.Add(TDBTimeEach)
AddHandler TDBTimeEach.Change, AddressOf TDBTimeEach_Change
Else
cb2 = dgPacking.GetCellBounds(dgPacking.CurrentRowIndex, 2)
TDBTimeEach.Location = New Point(cb2.X, cb2.Y)
TDBTimeEach.Size = New Size(cb2.Width, cb2.Height)
TDBTimeEach.Value = dgPacking.Item(dgPacking.CurrentRowIndex, 2)
dgPacking.Controls.Add(TDBTimeEach)
End If
TDBTimeEach.Visible = True
End If
End Sub
Sincerely,
Michael