Combobox in an ADO datagrid


I am a VB6 beginner, and I am looking to use an ADO datagrid with a combobox.  Basically I want to put the combobox on the current datagrid cell so that I can update the grid with a selection from the combo.  The problem I have is this:

I can do it OK with a flexgrid, as follows:

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Combo1.Visible = False
        Combo1.Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft
        Combo1.Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
        Combo1.Width = MSFlexGrid1.CellWidth
        Combo1.Visible = True
End Sub

but I want to use a datagrid because a databound flexgrid is only readonly, and I want to be able to update my database table automatically.  This I can do with a datagrid.  But I can find no way of referencing the datagrid cell in the necessary way.  Help!  Is this impossible with a datagrid???

Alternatively, does anyone know a freeware grid with the above capabilities (ie databinding and cell referencing).

Many thanks,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
Add a ListBox and make its visible property to False.

'Add this code to the form declaration

Option Explicit
Dim intColIdx As Integer
 'This will contain the index for the current  cell in the dbgrid
Dim blnListShow As Boolean 'is the list showing or not

Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer)
Dim intTop As Integer
intColIdx = ColIndex
If blnListShow = False Then 'if the list is not showing then...
blnListShow = True
List1.Left = DBGrid1.Columns(ColIndex).Left + 360
intTop = DBGrid1.Top + (DBGrid1.RowHeight * (DBGrid1.Row +2))
 List1.Top = intTop
 List1.Width = DBGrid1.Columns(ColIndex).Width + 15
                     List1.Visible = True
Else 'if the list is show, hide it
             blnListShow = False
              List1.Visible = False
End If
End Sub

Private Sub Form_Load()
   blnListShow = False 'initialize
End Sub

Private Sub List1_Click()
   DBGrid1.Columns(intColIdx).Text = List1.Text
   'set the value of the dbgrid
   List1.Visible = False 'hide the list
End Sub

Private Sub List1_LostFocus()
   blnListShow = False
   List1.Visible = False
End Sub  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.