unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;
type
TExtInplaceEdit =
class(TInplaceEdit)
protected
procedure CreateParams(
var Params: TCreateParams);
override;
end;
TExtStringGrid =
class(TStringGrid)
protected
function CreateEditor: TInplaceEdit;
override;
public
constructor Create(AOwner: TComponent);
override;
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
override;
end;
implementation
{ TExtInplaceEdit }
procedure TExtInplaceEdit.CreateParams(
var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style
or LongWord(ES_Center);
//Text des InplceEditors zentriert darstellen
end;
{ TExtStringGrid }
constructor TExtStringGrid.Create(AOwner: TComponent);
begin
inherited;
Parent := AOwner
as TWinControl;
DefaultColWidth := 75;
DefaultRowHeight := 20;
FixedCols := 0;
FixedRows := 0;
ColCount := 2;
RowCount := 4;
Width := 160;
Height :=90;
Options := Options + [goEditing];
Selection := TGridRect(Rect(-1,-1,-1,-1));
end;
function TExtStringGrid.CreateEditor: TInplaceEdit;
begin
Result := TExtInplaceEdit.Create(Self);
end;
procedure TExtStringGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
var s:
string;
begin
s := Cells[ACol, ARow];
//Text im Stringgrid zentriert darstellen
DrawText(Canvas.Handle, PChar(s), Length(s), ARect, DT_SINGLELINE
or DT_Center
or DT_VCENTER);
end;
end.