Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Color Combox auf TStringGrid (https://www.delphipraxis.net/182448-color-combox-auf-tstringgrid.html)

bernhard_LA 24. Okt 2014 23:31


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

Keldorn 25. Okt 2014 06:58

AW: Color Combox auf TStringGrid
 
Hallo,

gugg mal hier

Gruß Frank


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:04 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz