Skip to content

Commit fa73114

Browse files
committed
feat: prevent editing contents of generated columns in data grid
Refs #462
1 parent 5150a7f commit fa73114

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

source/main.pas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10995,13 +10995,24 @@ procedure TMainForm.AnyGridKeyDown(Sender: TObject; var Key: Word; Shift: TShift
1099510995

1099610996
procedure TMainForm.AnyGridEditing(Sender: TBaseVirtualTree; Node:
1099710997
PVirtualNode; Column: TColumnIndex; var Allowed: Boolean);
10998+
var
10999+
ColInfo: TTableColumn;
1099811000
begin
1099911001
Allowed := False;
1100011002
try
1100111003
if not AnyGridEnsureFullRow(Sender as TVirtualStringTree, Node) then
1100211004
ErrorDialog(_('Could not load full row data.'))
1100311005
else begin
1100411006
Allowed := True;
11007+
if Sender = DataGrid then begin
11008+
ColInfo := SelectedTableColumns.FindByName(Sender.Header.Columns[Column].Text);
11009+
if Assigned(ColInfo) then begin
11010+
Allowed := ColInfo.GenerationExpression.IsEmpty;
11011+
if not Allowed then
11012+
ErrorDialog(f_('Column %s is defined as generated. You cannot edit its content.', [Column.ToString]));
11013+
end;
11014+
end;
11015+
1100511016
// Move Esc shortcut from "Cancel row editing" to "Cancel cell editing"
1100611017
actDataCancelChanges.ShortCut := 0;
1100711018
actDataPostChanges.ShortCut := 0;

0 commit comments

Comments
 (0)