Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi StringGrid vergleichen! (https://www.delphipraxis.net/121064-stringgrid-vergleichen.html)

thiagojonas 25. Sep 2008 13:16

Re: StringGrid vergleichen!
 
Ich habe eine FixedRow,spielt das eine Rolle?

taaktaak 25. Sep 2008 18:13

Re: StringGrid vergleichen!
 
Tja, und nun?
Ich stelle fest, dass das Programm nicht anforderungsgemäß funktioniert.
Ohne den kompletten Source kann ich dir nix dazu sagen :|
Also, wenn du's nicht selbst auflösen kannst, dann musst du uns den mal zur Verfügung stellen - anders geht das nicht.

thiagojonas 25. Sep 2008 18:20

Re: StringGrid vergleichen!
 
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    air_dg: TStringGrid;
    fligths_dg: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    flugnummer: integer;
    function getFlugNummer: string;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.getFlugNummer: string;
begin
    result := format('%3.3d',[flugnummer + 1]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var Txt2Find : String;
    Index   : Integer;

function GetGrid2Index(Grid:TStringGrid;Txt2Find:String):Integer;
var i : Integer;
begin
  Result:=-1;
with Grid do
      for i:=FixedRows to RowCount-1 do
        if (fligths_dg.Cells[1,i]= Txt2Find) then begin
          Result:=i;
          Break;
          end;
  end;

begin
  Txt2Find:=air_dg.Cells[1,air_dg.Row];
  Index  :=GetGrid2Index(fligths_dg,Txt2Find);
  if Index>-1 then fligths_dg.Cells[5,Index] := FormatDateTime('hh:mm',now);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if air_dg.Cells[air_dg.FixedCols,Pred(air_dg.RowCount)] <> '' then
    air_dg.RowCount := Succ(air_dg.RowCount);
    air_dg.Cells[air_dg.FixedCols,Pred(air_dg.RowCount)] := getFlugNummer;
    air_dg.Cells[1,Pred(air_dg.RowCount)] := 'Hallo';
    air_dg.Cells[2,Pred(air_dg.RowCount)] := 'Rainer';
    air_dg.Cells[3,Pred(air_dg.RowCount)] := 'Horst';

 if fligths_dg.Cells[fligths_dg.FixedCols,Pred(fligths_dg.RowCount)] <> '' then
    fligths_dg.RowCount := Succ(fligths_dg.RowCount);
    fligths_dg.Cells[fligths_dg.FixedCols,Pred(fligths_dg.RowCount)] := getFlugNummer;
    fligths_dg.Cells[1,Pred(fligths_dg.RowCount)] := 'Hallo';
    fligths_dg.Cells[2,Pred(fligths_dg.RowCount)] := 'Rainer';
    fligths_dg.Cells[3,Pred(fligths_dg.RowCount)] := 'Horst';
    fligths_dg.Cells[4,Pred(fligths_dg.RowCount)] := FormatDateTime('hh:mm',now);
    fligths_dg.Cells[6,Pred(fligths_dg.RowCount)] := '';
   
  inc(flugnummer);
end;

end.
Meinst Du den? :-D

taaktaak 25. Sep 2008 18:24

Re: StringGrid vergleichen!
 
Joo, ich schau mir das nachher mal an

thiagojonas 25. Sep 2008 18:28

Re: StringGrid vergleichen!
 
Danke! :-D

taaktaak 25. Sep 2008 18:57

Re: StringGrid vergleichen!
 
Liste der Anhänge anzeigen (Anzahl: 1)
So,
wenn ich das richtig erfasst habe, dann ist der eigentliche Code schon OK. Deine Testdaten waren nicht geeignet: Es wird immer die Spalte 1 (das ist die ZWEITE, da Zählung bei 0 beginnt) verglichen; da steht bei dir immer nur HALLO drin - für den Test also ungeeignet. Habe das mal ein bisschen anders gemacht. Anbei Source in schlimmer Fomatierung.

thiagojonas 25. Sep 2008 19:47

Re: StringGrid vergleichen!
 
Super Danke das wars!:-)


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:07 Uhr.
Seite 4 von 4   « Erste     234   

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