unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ImgList, inifiles, Registry, Shellapi, MPlayer, Grids, jpeg, StrUtils, ComCtrls, XPMan, Gauges; type TForm1 = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; GroupBox1: TGroupBox; Button1: TButton; Button2: TButton; StringGrid1: TStringGrid; Memo1: TMemo; TabSheet2: TTabSheet; XPManifest1: TXPManifest; ProgressBar1: TProgressBar; StringGrid2: TStringGrid; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; implementation {$R *.dfm} function extraire(var chaine:string; separateur: string):string; var p: integer; begin p := pos(separateur, chaine); if p = 0 then begin Result := chaine; chaine := ''; end else begin result := copy(chaine, 1, p-1); delete(chaine, 1, p -1 + length(separateur)); end; end; procedure TForm1.Button1Click(Sender: TObject); Var F: TextFile; ligne: String; noLigne, noCol: integer; n1, n2: Variant; begin n1 := 0; n2 := 0; ProgressBar1.Position := 0; while n1 < 500000 do begin n2 := n2 + n1; Inc (n1); if (n1 mod 5000) = 0 then begin ProgressBar1.Position := n1 div 5000; Application.ProcessMessages; end; end; begin noLigne := 0; AssignFile(F,ExtractFilePath(Application.ExeName)+'test.txt'); Reset(F); repeat Readln(F, ligne); inc(noLigne); if noLigne + 1 > StringGrid1.RowCount then StringGrid1.RowCount := noLigne + 1; noCol := 0; repeat StringGrid1.Cells[noCol, noLigne] := extraire(ligne, #9); inc(noCol); until ligne = ''; if StringGrid1.Cells[5, noLigne] = 'erreur' then StringGrid1.Objects[0, noLigne] := TObject(0) else StringGrid1.Objects[0, noLigne] := TObject(1); until EOF(F); CloseFile(F); end; end; procedure TForm1.Button2Click(Sender: TObject); begin application.terminate; end; procedure TForm1.FormShow(Sender: TObject); begin StringGrid1.ColWidths[1] := 40; StringGrid1.ColWidths[2] := 40; StringGrid1.ColWidths[5] := 80; StringGrid1.ColWidths[3] := 100; StringGrid1.Rows[0].DelimitedText := '"N° de vol"'#9'"Date"'#9'"heure"'#9'"Nombre de ballon"'#9'"Activer"'#9'"Etat du laché"'; end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if ARow <> 0 then begin with StringGrid1, Canvas do begin if Objects[0, ARow] = Tobject(0) then Brush.Color := RGB(255, 200, 200) else Brush.Color := RGB(200, 255, 200); FillRect(Rect); DrawText(Canvas.Handle, PChar(Cells[ACol,ARow]), -1, Rect , DT_CENTER or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE); end; end; end; end. /b
With StringGrid2 do Begin Inc(RowCount); Rows[RowCount-1].AddStrings(StringGrid1.Rows[IndexLigneACopier]); End;
begin noLigne := 0; AssignFile(F,ExtractFilePath(Application.ExeName)+'test.txt'); Reset(F); repeat Readln(F, ligne); inc(noLigne); if noLigne + 1 > StringGrid1.RowCount then StringGrid1.RowCount := noLigne + 1; noCol := 0; repeat StringGrid1.Cells[noCol, noLigne] := extraire(ligne, #9); inc(noCol); until ligne = ''; if StringGrid1.Cells[5, noLigne] = 'erreur' then StringGrid1.Objects[0, noLigne] := TObject(0) else StringGrid1.Objects[0, noLigne] := TObject(1); With StringGrid2 do Begin Inc(RowCount); Rows[RowCount1].AddStrings(StringGrid1.Rows[IndexLigneACopier]); End; until EOF(F); CloseFile(F); end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionif StringGrid1.Cells[5, noLigne] = 'erreur' then Begin StringGrid1.Objects[0, noLigne] := TObject(0); With StringGrid2 do Begin Inc(RowCount); Rows[RowCount1].AddStrings(StringGrid1.Rows[noLigneeACopier]); End; end else...
if StringGrid1.Cells[5, noLigne] = 'erreur' then Begin StringGrid1.Objects[0, noLigne] := TObject(0); With StringGrid2 do Begin inc(RowCount1); RowCount := RowCount1+1; Rows[RowCount1].DelimitedText := StringGrid1.Rows[noLigne].DelimitedText; End; end else..
RowCount:= RowCount+1; Rows[RowCount-1]...