TMSFNCDataGrid ftTime-Field

When i´m using the TTMSFNCDigitalTimePicker in TTMSFNCDataGrid the Value is not correctly applied to the Grid in TTMSFNCDataGrid.OnAfterInplaceEditorSetValue instead it´s always set back to 00:00:00.

i´ve followed this tutorial and created following sample to show my issue:

Sample_DataGrid_Time.zip (14.8 KB)

Am i doing something wrong?

Hi,

You actually need the OnBefore* events, and the order needs to change SetValue is when the editor starts and sets the value from the cell to the editor, GetValue is when the editor closes and gets the value from the editor and puts it back to the cell

So replace OnAfterInplaceEditorGetValue & OnAfterInplaceEditorSetValue with

procedure TForm1.SampleGridBeforeInplaceEditorGetValue(Sender: TObject;
  ACell: TTMSFNCDataGridCellCoord; AInplaceEditor: TTMSFNCDataGridInplaceEditor;
  var AValue: TTMSFNCDataGridCellValue; var AHandled: Boolean);
begin
  if AInplaceEditor is TTMSFNCDigitalTimePicker then
  begin
    AValue := (AInplaceEditor as TTMSFNCDigitalTimePicker).SelectedTime;
    AHandled := True;
  end;
end;

procedure TForm1.SampleGridBeforeInplaceEditorSetValue(Sender: TObject;
  ACell: TTMSFNCDataGridCellCoord; AInplaceEditor: TTMSFNCDataGridInplaceEditor;
  var AValue: TTMSFNCDataGridCellValue; var AHandled: Boolean);
begin
  if AInplaceEditor is TTMSFNCDigitalTimePicker then
  begin
    (AInplaceEditor as TTMSFNCDigitalTimePicker).SelectedTime := AValue.AsType<TTime>;
    AHandled := True;
  end;
end;

Also, a small hint, when you want to have an automatic dropdown of the time picker (or any picker for that matter)

SampleGrid.Options.Editing.DirectDropDown := True;

This works perfectly. The small hint is really useful :grin:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.