Crash Course Delphi 19 [beta]:
CSV Files - part 6

Edit records: improved

A better way for editing records.

Analysis: editing a record

The easiest way to let the user change records, is by always allowing editing of the cells of the stringgrid. But when a stringgrid is always in "edit mode", this results in a some unwanted side effects:

  • It's much too easy to change the contents of cells by accident.
  • When a cell is clicked, by default the entire cell gets selected (hilighted). If you type something afterwards, the cell contents will be replaced by what you typed. But often this is not what you intended: you only wanted to modify or add a few characters. Delphi lets the user restore the previous cell contents by typing Control-Z... but what if she/he doesn't know this convention, and moves to another cell before pressing Ctrl-Z?

So, let's only enable editing on demand, when the user explicitly asks this by clicking option Edit in the menu, or by double clicking on a cell.
And secondly, let's deselect the cell contents after "edit mode" is clicked.


To be continued...