I am trying to make my datagrid editable, so that the user can type his data on the grid it self and it will be displayed in the datagrid.

On mousedown event of the grid I am trying to show the control on the screen, like text box, combobox.
Assuming that the user will enter data in the controls.

I succeeded in displaying the controls and adding the text to the gird.

But the problem is to get the focus on the control i again have to click on the control.
(First click to select the column then on column the control appears but with out focus to it, click on the control to set the focus and enter the data.)

the code is

hitTestGrid = dgBondBlotter.HitTest(e.X, e.Y)
If Not (hitTestGrid Is Nothing) Then
datagridtextBox = CType(dgBondBlotter.TableStyles(0).GridColumnStyles(hitTestGrid.Column), DataGridTextBoxColumn)
'Create the combo control to be added and set its properties
Select Case hitTestGrid.Column
Case 0 'Strategy

cmbStrategies = New ComboBox
cmbStrategies.Cursor = System.Windows.Forms.Cursors.Arrow
cmbStrategies.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
cmbStrategies.Dock = DockStyle.Fill

strSQL = "select Strategy from tblStrategies"
ds = objSQL.GetData(strSQL, "yieldcurve")
Try
If ds.Tables(0).Rows.Count > 0 Then
cmbStrategies.Items.Clear()
For i = 0 To ds.Tables(0).Rows.Count - 1
cmbStrategies.Items.Add(ds.Tables(0).Rows(i).Item("Strategy"))
Next
End If
Catch ex As Exception
End Try

cmbStrategies.SendToBack()

datagridtextBox.TextBox.Controls.Add(cmbStrategies)
cmbStrategies.BringToFront()
cmbStrategies.Focus()


Am I missing anything or is it the wrong way to do it?

Can you help me?

Thanks