Hi,
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);
begin
if (ACol = 2) and (ARow >= WebStringGrid1.FixedRows) then
begin
AEditor := geCustom;
WebStringGrid1.EditControl := MyEditControl;
end;
end;
- 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);
begin
Value := (AControl as TMyEditControl).Text;
end;
procedure TForm1.WebStringGrid1SetEditControlValue(Sender: TObject; ACol,
ARow: Integer; AControl: TControl; const Value: string);
begin
(AControl as TMyEditControl).Text := Value;
end;
With this technique, a TWebDropDpownControl using a TWebCalendar is used to create a date picker edit control in the grid:
applies to TWebDBGrid as well.
Ok, Bruno.
Thanks
Hello!
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
Can I create a separate form and use it as custom editor control?