Einzelnen Beitrag anzeigen

Benutzerbild von baumina
baumina

Registriert seit: 5. Mai 2008
Ort: Oberschwaben
1.275 Beiträge
 
Delphi 11 Alexandria
 
#13

AW: TStringGrid in Delphi7 und XE

  Alt 16. Sep 2013, 10:29
Also im XE hab ichs eben versucht, da funktioniert es noch, eine höhere Version habe ich leider nicht.

Delphi-Quellcode:
type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormActivate(Sender: TObject);
    procedure StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
var
   n : integer;
begin
 StringGrid1.RowCount:= 5;
 StringGrid1.ColCount:= 3;
 StringGrid1.Cells[0,0]:= 'LNr';
for n:= 1 to 4 do begin
   StringGrid1.Cells[0,n]:= IntToStr(n);
   StringGrid1.Cells[1,n]:= IntToStr(n*10);
   StringGrid1.Cells[2,n]:= IntToStr(n*100);
 end;
end;

procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 Label1.Caption:= StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row];
 Label2.Caption:= Form1.StringGrid1.Cells[Form1.StringGrid1.Col,Form1.StringGrid1.Row];
end;
Hinter dir gehts abwärts und vor dir steil bergauf ! (Wolfgang Ambros)
  Mit Zitat antworten Zitat