Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Gauge in Stringgrid (https://www.delphipraxis.net/39709-gauge-stringgrid.html)

jolomino 6. Feb 2005 20:26


Gauge in Stringgrid
 
hallo,
ist es möglich eine gauge in einer zelle eines stringgrids zu plazieren? habe die forumsuche echt schon überlastet :-D
wenn ja, wäre ein beispiel nicht schlecht

gruss jolomino

axelf98 6. Feb 2005 21:19

Re: Gauge in Stringgrid
 
Ich habs mal eben probiert.. Funktioniert aber beim Verkleinern der Zellen nicht perfekt...

Einfach ein Button und ein Stringgrid aufs Formular...

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Gauges, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var mGauge: TGauge;
begin
 mGauge := TGauge.Create(Stringgrid1);
 mGauge.Parent := stringgrid1;
 mGauge.Progress := 48;
 stringgrid1.Objects[2,2] := mGauge;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
  var tmpGauge : TGauge;
begin
 if (Acol = 2) AND (Arow = 2) then
 begin
  if stringgrid1.Objects[2,2] <> nil then
  begin
   tmpGauge := (stringgrid1.Objects[2,2] as TGauge);
   with tmpGauge do
   begin
    Left := Rect.Left;
    Top := Rect.Top;
    Width := Rect.Right - Rect.Left;
    Height := Rect.Bottom - Rect.Top;
   end;
  end;
 end;
end;

end.

jolomino 6. Feb 2005 21:55

Re: Gauge in Stringgrid
 
so erstmal danke und ich habs mal probiert, aber die gauge wird übers stringgrid gelagert, also links oben über 4 zellen und 1,5 spalten

Delphi-Quellcode:
unit Unit6;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Gauges, Grids;

type
  TForm6 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form6: TForm6;

implementation

{$R *.dfm}

procedure TForm6.Button1Click(Sender: TObject);
var mGauge: TGauge;
begin
mGauge := TGauge.Create(Stringgrid1);
mGauge.Parent := stringgrid1;
mGauge.Progress := 48;
stringgrid1.Objects[2,2] := mGauge;
end;

procedure TForm6.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
  var tmpGauge : TGauge;
begin
if (Acol = 2) AND (Arow = 2) then
begin
  if stringgrid1.Objects[2,2] <> nil then
  begin
   tmpGauge := (stringgrid1.Objects[2,2] as TGauge);
   with tmpGauge do
   begin
    Left := Rect.Left;
    Top := Rect.Top;
    Width := Rect.Right - Rect.Left;
    Height := Rect.Bottom - Rect.Top;
   end;
  end;
end;
end;

end.
müsste doch so passen oder?

gruss jolomino


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:56 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