How to use TAdvTouchSpinEdit as TAdvStringGrid editor ?

Hello,

Is it possible to use the TAdvTouchSpinEdit control as a SpinEdit control in TAdvStringGrid ?

Thank you,

--
Pierre Y.

I tried using a TEditLink descendant :

type
  TTouchSpinEditLink = class(TEditLink)
  private
    FSpinEdit: TAdvTouchSpinEdit;
  protected
    procedure EditExit(Sender:TObject);
  public
    procedure CreateEditor(AParent: TWinControl); override;
    procedure DestroyEditor; override;
    procedure SetCellProps(AColor: TColor; AFont: TFont); override;
    function GetEditorValue: string; override;
    procedure SetEditorValue(S: string); override;
    function GetEditControl: TWinControl; override;
  end;

Implemented as :

{ TTouchSpinEditLink }

procedure TTouchSpinEditLink.CreateEditor(AParent: TWinControl);
begin
   FSpinEdit := TAdvTouchSpinEdit.Create(Grid);
   FSpinEdit.BorderStyle := bsNone;
   FSpinEdit.OnKeydown := EditKeyDown;
   FSpinEdit.OnExit := EditExit;
   FSpinEdit.Width := 0;
   FSpinEdit.Height := 0;
   FSpinEdit.Parent := AParent;
//   WantKeyLeftRight := True;
//   WantKeyHomeEnd := True;
end;

procedure TTouchSpinEditLink.DestroyEditor;
begin
  if Assigned(FSpinEdit) then
    FSpinEdit.Free;
  FSpinEdit := nil;
end;

procedure TTouchSpinEditLink.EditExit(Sender: TObject);
begin
//  HideEditor;
end;

function TTouchSpinEditLink.GetEditControl: TWinControl;
begin
  Result := FSpinEdit;
end;

function TTouchSpinEditLink.GetEditorValue: string;
begin
  Result := FSpinEdit.Text;
end;

procedure TTouchSpinEditLink.SetCellProps(AColor: TColor; AFont: TFont);
begin
  FSpinEdit.Color := AColor;
  FSpinEdit.Font := AFont;
end;

procedure TTouchSpinEditLink.SetEditorValue(S: string);
begin
  FSpinEdit.Text := S;
end;

It "almost" work...

I have another problem when I want to "exit" the edit mode by clicking another row, given that only the "Utilisés" column can be edited, the edited value is also copied to the new row.

Can you help me make this work ?

Regards,

--
Pierre Y.

  1. Do I assume correct that your problem is that the text is sort of half displayed? If so, is this a high DPI situation? What is the version of TMS VCL UI Pack and the version of the IDE?
  2. Your grid settings, version, event handlers, code might affect this. If this is using TMS VCL UI Pack v11.0.3.0, please send a sample source test project with which we can reproduce this so we know all details.

Hi Bruno,

Thank you for answering,

Yes, the text is half displayed when I use anything else than the default form font. I'm using the latest VCL UI Pack, my AdvStringGrid version is 8.7.1.7 from Jan, 2023

My display is configured with 150% scaling.

I retested using Delphi 10.2 and Delphi 11.2 but on 150% DPI I could not see an issue with TAdvTouchSpinEdit embedded in the grid as inplace editor.
If a problem persists using TMS VCL UI Pack v11.0.3.0, please send a sample source test project with which we can reproduce this so we know all details.

Hi Bruno,

(In fact, I have not the latest VCL UI Pack, but one point release before : 11.0.2.0)

In a test project, I can't reproduce the HDPI Text scaling issue. But I can reproduce all other "glitches" in User eXperience : try entering in EditMode, change something then leave editing by clicking another cell in the 4th column (only cells from 4th column are editable)

I sent an email yesterday (not sure if it was delivered because it was sent using a never configured Windows Courrier...) regarding a crash in TAdvStringGrid while deserializing the form DFM : RowHeights : Incorrect Property Value. I circumvent this one by creating the grid by code. You can see it in action by clicking the "Open Broken Form" button. Hope it will crash for you too, I'm totally fuzzed by this one.

What's strange is that this form can be opened by the designer : everything works ok for several "rounds" of tweak the grid / tweak the code / run / test / stop app or kill app by the debugger, ... rinse and repeat. When the RowHeights property appears in the DFM, removing it by hand don't fix the problem.

Please note that I'm using Delphi 11.2 with LSP Patch applied and Navigator plugin installed (from GetIt) I have lots of crashes due to the Navigator plugin but I can't work without it.

AdvGridWithTouchSpin.zip (96.7 KB)

Thank you for paying attention to my problems :slight_smile:

--
Pierre Y.

I could see these issues in Delphi 11.2.

  1. About the RowHeights, I'm not sure what is causing this. I have seen this problem before also in the VCL base class TStringGrid. RowHeights is inherited from this base class. I suspect this is due to property streaming order, where the RowCount is not yet the expected value when the form streaming reads RowHeights. Sadly, I have not been able to find if this can be workarounded.
  2. About the use of TAdvTouchSpinEdit, this must be something in your EditLink class you wrote for this. I did a setup with our TFormControlEditLink and I could not longer see an issue. The modified project with the TFormControlEditLink is here.
    AdvGridWithTouchSpin.zip (97.9 KB)