Just follow the given steps:
Step1:
Place a combo box any where in the form and populate the values as you need. Set the visible property to false in design time itself.
Step2:
Now we can set the combo box on any cell of the selected column, let’s say on column 7.
The fallowing code shlould write in the row column change event of the data grid
Here cmbGridDisposition is the name of the requred combo box.
Code:
If rptGrid.Col = 7 Then
cmbGridDisposition.Visible = True
cmbGridDisposition.Top = rptGrid.Columns(7).Top
rptGrid.RowHeight = cmbGridDisposition.Height
cmbGridDisposition.Top = rptGrid.Columns(7).Top + rptGrid.Top + rptGrid.RowTop(rptGrid.Row)
cmbGridDisposition.Top = cmbGridDisposition.Top - 200
cmbGridDisposition.Width = rptGrid.Columns(7).Width
cmbGridDisposition.Left = rptGrid.Columns(7).Left + rptGrid.Left
If Len(rptGrid.Columns(7).Text) > 0 Then
cmbGridDisposition = rptGrid.Columns(7).Text
End If
Else
cmbGridDisposition.Visible = False
End If
This will work only if the cell value matched with the list of combo box values.
Step3:
To affect the selected value from the drop down over the grid cell. We should write code under the
Click event of the combo box.
Code:
If cmbGridDisposition.Visible = True Then
rptGrid.Columns(7).Text = cmbGridDisposition.Text
End If
By running the code you can able to select value for a particular column from the drop down list.
Bookmarks