![]() |
Color Combox auf TStringGrid
Liste der Anhänge anzeigen (Anzahl: 1)
Ich habe im Internet eine fertige Komponente gefunden um Daten in einem Stringrid über eine Combobox bzw. einen Input-Dialog einzugeben. Nun möchte ich aber meine selbst gebaute TFarbbox als Erweiterung einer TCombobox als Eingabekomponente verwenden. Wie geht denn sowas?????
Delphi-Quellcode:
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 und die Farbbox Komponente dazu
Delphi-Quellcode:
TFarbBox = class(TComboBox)
private { Private-Deklarationen } function GetColor: TColor; protected { Protected-Deklarationen } procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);override; procedure CreateWnd; override; public { Public-Deklarationen } constructor Create(AOwner: TComponent);override; published { Published-Deklarationen } property color : TColor read GetColor; end; Anlage ist das Grid Version heute, in der nächsten Version bewirkt ein Click auf eine Farbe eine Anzeige der FarbCombobox und der User kann die neue Farbe auswählen |
AW: Color Combox auf TStringGrid
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:51 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