Option Explicit
Private Sub datagrid1_MouseUp(Button As Integer, _
Shift As Integer, x As Single, y As Single)
Static CurrentWidth As Single
' Check to see if the columns(1).'s width has changed.
If DataGrid1.Columns(1).Width <> CurrentWidth Then
Combo1.Width = DataGrid1.Columns(1).Width
CurrentWidth = DataGrid1.Columns(1).Width
End If
End Sub
Private Sub Form_Load()
Combo1.Visible = False
Combo1.ZOrder (0)
Combo1.Width = DataGrid1.Columns(2).Width
' Load the ComboBox's list.
Combo1.AddItem "Some text"
Combo1.AddItem "Some more text"
Combo1.AddItem "Still more text"
Combo1.AddItem "Yet even more text"
Combo1.AddItem "Way more text than that"
End Sub
Private Sub datagrid1_Click()
' Position and size the ComboBox, then show it.
Combo1.Top = DataGrid1.Columns(2).Top
Combo1.Width = DataGrid1.Columns(2).Width
Combo1.Left = DataGrid1.Columns(2).Left + DataGrid1.Left
Combo1.Top = DataGrid1.Columns(2).Top + DataGrid1.Top
Combo1.Text = DataGrid1.Columns(2).Text
Combo1.Visible = True
End Sub
Private Sub Combo1_Click()
' Place the selected item into the columns(1). and hide the
ComboBox.
DataGrid1.Columns(2).Text = Combo1.Text
Combo1.Visible = False
End Sub
Before using this code connect the datagrid to any table of your data base
that you
want to update.