How to limit the input in the rdbgrid cell only to the values ​​of the associated picklist.

24 views
Skip to first unread message

Giuseppe Borgobello

unread,
Dec 6, 2024, 6:14:18 AM12/6/24
to Rosi Delphi Components
Hello everyone,
I would like to limit the input in a cell (column) of an rdbgrid to only the values ​​present in its picklist, without the user being able to modify the cell with the keyboard. Is there a way to achieve this?
Thanks
Giuseppe

Tomas Rosinsky

unread,
Dec 8, 2024, 10:54:53 AM12/8/24
to Rosi Delphi Components
HI Giuseppe, 

there are 2 possible solutions.

1/ use lookup field with list of values (key field and value field can have same values) and then only values from the list can be selected

2/ use OnKeyPress event and block editing for the field with picklist

procedure TrDBGrid2.gr2KeyPress(Sender: TObject; var Key: Char);
begin
  if gr2.SelectedField=SomeField then
    Key:=#0;
end;
 
I hope it helps
Tomas
Dne pátek 6. prosince 2024 v 12:14:18 UTC+1 uživatel g.borg...@cracra.it napsal:
Reply all
Reply to author
Forward
0 new messages