Hello
I've a TTMSFNCGrid Grid in a form. It's bduild by code.
12 columns, 5 are Dates.
We explictly use the editor property to set the right editor.
We CAN modify the value from blank to a real date.
We validate the record.
Next we want to change the date from a real date value to blank But the delete key nor the backspace key doesn't clear the cell.
How to do that ? We tried with other kind of fields and it works fine with text or numerical value.
thank you.
I faced the same problem. My solution was to use the OnKeyDown event of the grid as follows:
var
{
Emptying the selected cell when key VK_DELETE is pressed
// r = Focused Row
// c = Focused Column
}
c, r: integer;
begin
r := Grid.FocusedCell.Row;
c := Grid.FocusedCell.Col;
if not Grid.Options.Editing.Enabled then
exit
else
if (Key = VK_DELETE) then
try
Grid.Cells[c, r] := '';
except
// whatever
end;
end;
Hello Joachim,
it works.
I've made a change because the Grid is linked to a TDatasource :
uses LCLType;
procedure TMyForm.TMSFNCGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
{
Emptying the selected cell when key VK_DELETE is pressed
// r = Focused Row
// c = Focused Column
}
c, r: integer;
Grid : TTMSFNCGrid;
column : TTMSFNCGridDatabaseAdapterColumn;
begin
Grid := TMSFNCGrid1;
r := Grid.FocusedCell.Row;
c := Grid.FocusedCell.Col;
if not Grid.Options.Editing.Enabled then
exit
else
if (Key = VK_DELETE) OR (Key = VK_BACK) then
try
begin
column := TMSFNCGridDatabaseAdapter1.Columns[c];
DSGrid.DataSet.Edit;
DSGrid.DataSet.FieldByName(column.FieldName).Clear;
end;
except
// whatever
end;
end;
There are other problems with the Grid. I create a new post for that with a video to show them.