![]() |
InplaceEditor von Stringgrid zentrieren
Hallo gibt es eine Möglichkeit den InplaceEditor bei jeder eingabe in eine Stringgrid-Zelle zu zentrieren?
|
Re: InplaceEditor von Stringgrid zentrieren
Ist es nicht irgendwie möglich mit der Funktion
Delphi-Quellcode:
bei der Erstellung des InplaceEditor das oben beschriebene zu erreichen?
function CreateEditor: TInplaceEdit; override;
In der Art zB:
Delphi-Quellcode:
Was aber leider nicht klappt...
function TEigenesStringgrid.CreateEditor;
var CustomInplace: TInplaceEdit; begin CustomInplace := TInplaceEdit.Create(self); CustomInplace.Left := 20; Result := CustomInplace; end; |
Re: InplaceEditor von Stringgrid zentrieren
|
Re: InplaceEditor von Stringgrid zentrieren
So ich habe es jetzt endlich gelöst hier meine Lösung: :bounce2:
Delphi-Quellcode:
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. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:10 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz