How to use Custom editor in TWebDbGrid? (release 2.2)

How to use Custom editor in TWebDbGrid? (release 2.2)
I want to test a custom editor (a custom dblookup with a grid in popup) to use in a Dbgrid. I need an example for start, thanks.

What is explained in the blog TMS Software | Blog

Custom cell editors in TWebStringGrid

Now, you can use any other control as inplace editor for a grid cell. This is achieved via:

  • implement OnGetCellEditor and return as editor type geCustom. For example, to edit column 2 with a custom inplace editor, use:
procedure TForm1.WebStringGrid1GetCellEditor(Sender: TObject; ACol,
 ARow: Integer; var AEditor: TGridCellEditor);
 if (ACol = 2) and (ARow >= WebStringGrid1.FixedRows) then
 AEditor := geCustom;
 WebStringGrid1.EditControl := MyEditControl;
  • in addition, two event handlers allow to transfer the cell data to the inplace editor and vice versa. This becomes something like:
 procedure TForm1.WebStringGrid1GetEditControlValue(Sender: TObject; ACol,
 ARow: Integer; AControl: TControl; var Value: string);
 Value := (AControl as TMyEditControl).Text;
procedure TForm1.WebStringGrid1SetEditControlValue(Sender: TObject; ACol,
 ARow: Integer; AControl: TControl; const Value: string);
 (AControl as TMyEditControl).Text := Value;

With this technique, a TWebDropDpownControl using a TWebCalendar is used to create a date picker edit control in the grid:

TMS Software Delphi Components

applies to TWebDBGrid as well.

Ok, Bruno.


Is possible to get an example of acustom editor control? I'm trying to create a panel with a + and - button and an TWebEdit for manual in put, but I'm clueless how to do it :slight_smile:


Can I create a separate form and use it as custom editor control?

Nevermind, found it here: Custom control development - TMS WEB Core

1 Like