View Issue Details

IDProjectCategoryView StatusLast Update
0024661LazarusLCLpublic2021-01-23 10:18
ReporterK155LA3 Assigned ToJesus Reyes  
Status closedResolutionwon't fix 
OSWindows 7, Windows XP 
Product Version1.0.8 
Summary0024661: Additional features for Stringgrid.

Some users to edit the table is used in conjunction with key combination 'Ctrl+C', 'Ctrl+V' and 'Ctrl+X', other key combination, such as 'Ctrl+A', 'Ctrl+Ins', 'Shift+Ins', 'Shift+Del' and 'Del':
1 Select all cells by 'Ctrl+A'.
2 'Ctrl+Ins' as alternative 'Ctrl+C'.
3 'Shift+Ins' as alternative 'Ctrl+V'.
4 'Shift+Del' as alternative 'Ctrl+X'.
5 'Del' to clear selected cells.

Steps To Reproduce1 Add to class description 'TCustomGrid' in section 'protected':
procedure DoDeleteSelection; virtual;

2 Add procedure TCustomGrid.DoDeleteSelection:
procedure TCustomGrid.DoDeleteSelection;

3 Add to class description 'TCustomStringGrid' in section 'protected':
procedure DoDeleteSelection; override;

4 Add procedure TCustomGrid.DoDeleteSelection:
procedure TCustomStringGrid.DoDeleteSelection;
  if EditingAllowed(Col) then Clean(Selection, []);

5 Add to 'case Key of' in procedure TCustomGrid.KeyDown:
      if not FEditorKey then begin
        if ssCtrl in Shift then begin //Select all Ctrl+A
          Key := 0;
          Selection := R;
        if not FEditorKey then begin
          if ssShift in Shift then begin //Alternative Ctrl+X
            Key := 0;
          if not(ssShift in Shift) then begin //Delete selected region
            Key := 0;
      if not FEditorKey then begin
        if ssCtrl in Shift then begin //Alternative Ctrl+C
          Key := 0;
        if ssShift in Shift then begin //Alternative Ctrl+V
          Key := 0;
TagsNo tags attached.
Fixed in Revision
Attached Files



2013-06-25 21:25


Stringridaddfeatures.gif (43,969 bytes)   
Stringridaddfeatures.gif (43,969 bytes)   


2013-06-25 21:26

reporter (777,319 bytes)

Zeljan Rikalo

2013-06-26 11:49

developer   ~0068551

Jesus, pls take care of this.


2013-06-26 22:47

reporter   ~0068577

In my project i need 'Ctrl+A' and 'Del' key combination to edit stringgrid data.
'Ctrl+Ins', 'Shift+Ins' and 'Shift+Del' key combination if I remember correctly still in use since the DOS.


2013-06-27 10:30

developer   ~0068585

I' against hard-coding key sequences into components, they may be inappropriate in other contexts. In the particular situation, it would not be too difficult for the reporter to achieve the desired funtionality at application level by means of the events provided by TStringGrid.


2013-07-05 07:13

reporter   ~0068718

The 'Ctrl+A' and 'Del' standard keyboard shortcuts (see MS Exel or Libre Office Calc), besides, it is convenient.
For example you can place on form stringgrid and set Row = 100 and Col = 100, then try fill them, select all cells and clear them.
If used multiple stringgrid, it is necessary for each to write the one and same code that handles keystrokes. Of course you can use the one function for all, but then there is the problem of determining what kind of stringgrid calling this function, and you need write a lot of redundant code in the program.If you change the name of a stringgrid or changing their number, it is necessary to make changes to this function, which is inconvenient.
The key combination 'Ctrl+Ins', 'Shift+Ins' and 'Shift+Del' is not necessary, but it used in Windows and work fine.

Bart Broersma

2013-07-05 10:08

developer   ~0068720

@K155LA3 Remeber that the use of Ctlr key for Key combo's is not the standard on MacOS.
So, even if we implement fixed shortcuts, don't uses ssCtrl, but use ssModifier (it maps to ssMeta on MacOS, to ssCtrl on other platforms).


2013-07-05 14:15

developer   ~0068722

If all required code would be available as public methods it would would not be too much effort to call them from appropriate event handlers shared between several string grids.


2013-07-05 22:18

reporter   ~0068724

Last edited: 2013-07-05 22:19

View 2 revisions

@Bart Broersma Thank you for your remark. I'm used only Windows OS.
N.B.: In 'case Key of' in procedure TCustomGrid.KeyDown in 'VK_C', 'VK_V', 'VK_X' used ssCtrl.

@wp In Lazarus-1.1-41901-fpc-2.6.2-20130626-win32 TCustomGrid.KeyDown proced VK_DELETE, but it only clear current cell and show editor.
I think the need to support standard keyboard shortcuts such as 'Ctrl+A' and 'Del' ('Ctrl+Ins', 'Shift+Ins' and 'Shift+Del' is desirable). Otherwise, every time when used a stringgrid will have to write additional code.
As solution: add an additional flag in the TGridOptions that will allow the use of these additional shortcuts.

John Kozikopoulos

2013-08-01 08:29

reporter   ~0069191

Last edited: 2013-08-01 08:30

View 2 revisions

let me propose a different solution that will avoid hard coding key sequences to the controls. Extend the default Edit actions for select all, copy, paste, etc to handle the stringgrid as well as custom edits.

This way the end user will have to only add the actions in the form/application and everything will be handled for him.

Jesus Reyes

2021-01-20 00:35

developer   ~0128440

Last edited: 2021-01-20 00:38

View 3 revisions

Sorry @K155LA3, I'm with @wp on this, system (or application) specific keyboard shortcuts should be handled by the user probably in a shared handler. Lazarus is smart enough to rename a shared handler, also if there is something that is difficult (and specially impossible) to do out of the grids code we can help in that.


2021-01-21 20:31

reporter   ~0128470

Hello, Jesus Reyes. It's not a problem for me to add such functionality. A simple class substitution trick adds not only hotkey functionality, but even undo/redo functionality, and everything works fine in runtime.
P.S.: The issues is still open and . The first problem was solved in version 1.3, the second - I don't know when, but in the current version everything works fine. They also need to be closed.

Jesus Reyes

2021-01-22 23:11

developer   ~0128496

Thank you, I resolved both reports. Closing issues is something reserved to the reporters when their report has been resolved, so please mark the reports as resolved in order to terminate their life cycle.


2021-01-23 10:18

reporter   ~0128499

No more required.

Issue History

Date Modified Username Field Change
2013-06-25 21:25 K155LA3 New Issue
2013-06-25 21:25 K155LA3 File Added: Stringridaddfeatures.gif
2013-06-25 21:26 K155LA3 File Added:
2013-06-26 11:49 Zeljan Rikalo LazTarget => -
2013-06-26 11:49 Zeljan Rikalo Note Added: 0068551
2013-06-26 11:49 Zeljan Rikalo Assigned To => Jesus Reyes
2013-06-26 11:49 Zeljan Rikalo Status new => assigned
2013-06-26 22:47 K155LA3 Note Added: 0068577
2013-06-27 10:30 wp Note Added: 0068585
2013-07-05 07:13 K155LA3 Note Added: 0068718
2013-07-05 10:08 Bart Broersma Note Added: 0068720
2013-07-05 14:15 wp Note Added: 0068722
2013-07-05 22:18 K155LA3 Note Added: 0068724
2013-07-05 22:19 K155LA3 Note Edited: 0068724 View Revisions
2013-08-01 08:29 John Kozikopoulos Note Added: 0069191
2013-08-01 08:30 John Kozikopoulos Note Edited: 0069191 View Revisions
2021-01-20 00:35 Jesus Reyes Status assigned => resolved
2021-01-20 00:35 Jesus Reyes Resolution open => won't fix
2021-01-20 00:35 Jesus Reyes Widgetset Win32/Win64 => Win32/Win64
2021-01-20 00:35 Jesus Reyes Note Added: 0128440
2021-01-20 00:36 Jesus Reyes Note Edited: 0128440 View Revisions
2021-01-20 00:38 Jesus Reyes Note Edited: 0128440 View Revisions
2021-01-21 20:31 K155LA3 Note Added: 0128470
2021-01-22 23:11 Jesus Reyes Note Added: 0128496
2021-01-23 10:18 K155LA3 Status resolved => closed
2021-01-23 10:18 K155LA3 Note Added: 0128499