Search code examples
delphisubclassingdbgridpicklist

Custom dbgrid and Picklist issue


I'm creating my own DBGRid, and it works fine , except of the pick list. whatever button style is set for the grid, it always shows the inplace editor , neither the pick list nor the ellipse button !

i can not figure the mistake I'm doing :( . here is the relevant code :

function TMyDBGrid.CreateEditor: TInplaceEdit;

begin
result:=TInplaceEdit.Create(self);

end;

function TMyDBGrid.GetEditStyle(ACol, ARow: integer): TEditStyle;
begin
 case Columns[ACol].ButtonStyle of
  cbsAuto : Result:=esPickList;
  cbsNone : result:=esSimple;
  cbsEllipsis : result:=esEllipsis;
end;
end;

And the constructor and destructor just call inherited , with the constructor just setting some colors for the grid.


Solution

  • The reason there's no pick list or button is that you are using an TInplaceEdit as the cell editor which does not support the functionality you need.

    The TDBGrid uses an TDBGridInplaceEdit that inherits from TInplaceEditList as its in place editor which integrates a TCustomListbox for its drop down list and paints and manages the edit button.