The Microsoft FlexGrid (MSFlexGrid) control displays and operates on tabular data. It allows complete flexibility to sort, merge, and format tables containing strings and pictures. When bound to a Data control, MSFlexGrid displays read-only data.
Unfortunately, the FlexGrid does not allow for direct editing. But there is a workaround. There are several steps for this.
1) On your form, first place the Grid (grdGrid). Then on top of the grid, add a TextBox (txtGrid) and a ComboBox (cboGrid)
2) Set the .Visible property of both the combobox and the Textbox to False
In your form, drop in the following three event handlers
Private Sub grdGrid_Click()
Select Case grdGrid.Col
Case 0, 3, 5 ' Columns that need Text Boxes
ActivateControl txtGrid, grdGrid
Case 1, 2, 4 ' Columns that need a Combo Box
<Load the Combo Box with Values>
ActivateControl cboGrid, grdGrid
Case Else
' Column is not editable
End Select
End Sub
Private Sub cboGrid_LostFocus()
ResetSetGrid cboGrid, grdGrid
End Sub
Private Sub txtGrid_LostFocus()
ResetSetGrid txtGrid, grdGrid
End Sub
Now in a module (or in the same form), drop in the following two public subroutines
Public Sub ActivateControl(rCtl_Control As Control, rGrd_grdGrid As MSHFlexGrid)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.