Edit Data in a Read Only Grid (MSFlexGrid)
Version Compatibility: Visual Basic 6
The arrow keys allow you to navigate through the cells in the grid. When you click a cell or press the Enter or Tab key, the textbox is displayed so that you can make your changes. Once in this "Edit" mode, the horizontal arrow keys can be used to move through the textbox's data. Pressing the vertical arrow, Enter or Tab key transfers the data back to the grid and takes you out of "Edit" mode.
I check to make sure that clicking on a fixed row or column in the grid does not display the textbox. Also, I make sure the grid and textbox use the same size and style of font so that the textbox aligns correctly by setting these properties manually in the form's load event. You can add additional code to the textbox to validate and format the data before writing it back to the grid and to align it left or right so that it looks the same in the textbox as it does in the grid.
Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.