type T2cccStringGrid = class(TStringGrid) protected function CreateEditor: TInplaceEdit; override; function GetEditStyle(ACol, ARow: Longint): TEditStyle; override; procedure EditListGetItems(ACol, ARow: Integer; Items: TStrings); procedure EditButtonClick(Sender: TObject); end; TStringGrid = class(T2cccStringGrid);
TForm1 = class(TForm) StringGrid1: TStringGrid; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
function T2cccStringGrid.CreateEditor: TInplaceEdit; begin Result := TInplaceEditList.Create(Self); (Result as TInplaceEditList).OnGetPickListitems := EditListGetItems; (Result as TInplaceEditList).OnEditButtonClick := EditButtonClick; end;
function T2cccStringGrid.GetEditStyle(ACol, ARow: Integer): TEditStyle; begin case ACol mod 2 of 0: Result := esEllipsis; 1: Result := esPickList; else Result := inherited GetEditStyle(ACol, ARow); end; end;
procedure T2cccStringGrid.EditListGetItems(ACol, ARow: Integer; Items: TStrings); begin case ACol mod 2 of 0: Items.CommaText := '2ccc,delphibox,zizii'; 1: Items.CommaText := 'welcome,stringgrid,demo'; end; end;
procedure T2cccStringGrid.EditButtonClick(Sender: TObject); begin Cells[Col, Row] := 'Hello 2ccc'; end;