unit unit_TCustomStringGrid;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Grids;
type
TGetEditStyleEvent =
procedure (TSender:TObject; ACol,ARow:integer;
var EditStyle:TEditStyle)
of object;
TCustomStringGrid =
class(TStringGrid)
private
FDropdownRowCount : integer;
FOnEditButtonClick : TNotifyEvent;
FOnGetEditStyle : TGetEditStyleEvent;
FOnGetPickListItems : TOnGetPickListItems;
procedure SetDropdownRowCount(value:integer);
procedure SetOnEditButtonClick(value:TNotifyEvent);
procedure SetOnGetPicklistItems(value:TOnGetPickListItems);
protected
function CreateEditor: TInplaceEdit;
override;
function GetEditStyle(ACol, ARow: integer): TEditStyle;
override;
public
constructor Create(AOwner:TComponent);
override;
published
property DropdownRowCount : integer
read FDropDownRowCount
write SetDropdownRowCount
default 8;
property OnEditButtonClick: TNotifyEvent
read FOnEditButtonClick
write SetOnEditButtonClick;
property OnGetEditStyle : TGetEditStyleEvent
read FOnGetEditStyle
write FOnGetEditStyle;
property OnGetPickListItems : TOnGetPickListItems
read FOnGetPickListItems
write SetOnGetPickListItems;
end;
procedure Register;
implementation
constructor TCustomStringGrid.Create(AOwner:TComponent);
begin
...
end;
function TCustomStringGrid.CreateEditor: TInplaceEdit;
begin
result := TInplaceEditList.Create(self);
with TInplaceEditList(result)
do begin
DropdownRows := FDropdownRowCount;
OnGetPickListItems := FOnGetPickListItems;
OnEditButtonClick := FOnEditButtonClick;
end;
end;
function TCustomStringGrid.GetEditStyle(ACol,ARow:integer) : TEditStyle;
begin
result := esSimple;
if Assigned(FOnGetEditStyle)
then FOnGetEditStyle(self, ACol, ARow, result);
end;
procedure TCustomStringGrid.SetDropDownRowCount(value:integer);
begin
FDropdownRowCount := value;
if Assigned(InplaceEditor)
then TInplaceEditList(InplaceEditor).DropdownRows := value;
end;
procedure TCustomStringGrid.SetOnEditButtonClick(value:TNotifyEvent);
begin
FOnEditButtonClick := value;
if Assigned(InplaceEditor)
then TInplaceEditList(InplaceEditor).OnEditButtonClick := value;
end;
procedure TCustomStringGrid.SetOnGetPicklistItems(value:TOnGetPicklistItems);
begin
FOnGetPicklistItems := value;
if Assigned(InplaceEditor)
then TInplaceEditList(InplaceEditor).OnGetPickListitems := value;
end;
procedure Register;
begin
RegisterComponents('
Samples', [TCustomStringGrid]);
end;
end