![]() |
StringGrid ausrechnen??
Ich versuche seit einigerzeit einen stringgrid auszurechnen, jedoch stellt sich mir delphi als eine unüberwindbare wand dar und lässt mich leiden!hier soweit ich bin nur das ausrechnen der zellen geht nicht
beispiels weise steht in der aritmatik: minus #9 12 #9 23 usw. (#9 tab)
Delphi-Quellcode:
kann mir einer helfen das problem zu bewältigen?
type
TForm1 = class(TForm) Panel: TPanel; Open: TButton; save: TButton; calculate: TButton; StringGrid: TStringGrid; OpenDialog: TOpenDialog; SaveDialog: TSaveDialog; Transport: TButton; procedure OpenClick(Sender: TObject); procedure TransportClick(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.OpenClick(Sender: TObject); begin opendialog.Execute; // RichEdit.Lines.LoadFromFile(opendialog.FileName); // opendialog.Execute; // richedit.linies. // stringGrid.Cells[1,1] := 'fdggjkfdgjkg';//.LoadFromFile(opendialog.FileName); end; procedure TForm1.TransportClick(Sender: TObject); var f: textfile; Spalte1,spalte2: String; i, count: Integer; delimiter: char; mylist : tstringlist; begin opendialog.Execute; mylist := TStringList.Create; mylist.LoadFromFile(Opendialog.FileName); mylist.Delimiter := #9; mylist.DelimitedText := mylist.Text; count := 0; i:=0; // if then ; while count < mylist.Count do begin stringgrid.Cells[1,i+1] := mylist.Strings[count]; stringgrid.Cells[2,i+1] := mylist.Strings[count+1]; stringgrid.Cells[3,i+1] := mylist.Strings[count+2]; count := count + 3; inc(i); end; end; end. |
Re: StringGrid ausrechnen??
Ein StringGrid heißt so, weil in ihm Strings (Text) stehen.
|
Re: StringGrid ausrechnen??
wollte nur einmal posten wie es nun aussieht! porblem gelöst
Delphi-Quellcode:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Grids; type TForm1 = class(TForm) Panel: TPanel; Open: TButton; save: TButton; calculate: TButton; StringGrid: TStringGrid; OpenDialog: TOpenDialog; SaveDialog: TSaveDialog; Transport: TButton; Button: TButton; procedure OpenClick(Sender: TObject); procedure TransportClick(Sender: TObject); procedure ButtonClick(Sender: TObject); procedure StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure FormShow(Sender: TObject); private ergebnis: real; { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.OpenClick(Sender: TObject); begin opendialog.Execute; // RichEdit.Lines.LoadFromFile(opendialog.FileName); // opendialog.Execute; // richedit.linies. // stringGrid.Cells[1,1] := 'fdggjkfdgjkg';//.LoadFromFile(opendialog.FileName); end; procedure TForm1.TransportClick(Sender: TObject); var f: textfile; Spalte1,spalte2: String; i, count: Integer; delimiter: char; mylist : tstringlist; begin opendialog.Execute; mylist := TStringList.Create; mylist.LoadFromFile(Opendialog.FileName); mylist.Delimiter := #9; mylist.DelimitedText := mylist.Text; count := 0; i:=0; // if mylist.Strings[count] = 'minus' then ; // mylist.strings[count+3]:= inttostr(strtoint(mylist.Strings[count+1])-strtoint(mylist.Strings[count+2])); ergebnis:=0; while count < mylist.Count do begin stringgrid.Cells[1,i+1] := mylist.Strings[count]; stringgrid.Cells[2,i+1] := mylist.Strings[count+1]; stringgrid.Cells[3,i+1] := mylist.Strings[count+2]; if mylist.Strings[count] = 'minus' then stringgrid.Cells[4,i+1] := inttostr(strtoint(mylist.Strings[count+1]) - strtoint(mylist.Strings[count+2])); if mylist.Strings[count] = 'summe' then stringgrid.Cells[4,i+1] := inttostr(strtoint(mylist.Strings[count+1]) + strtoint(mylist.Strings[count+2])); if mylist.Strings[count] = 'mal' then stringgrid.Cells[4,i+1] := inttostr(strtoint(mylist.Strings[count+1]) * strtoint(mylist.Strings[count+2])); if mylist.Strings[count] = 'teilen' then stringgrid.Cells[4,i+1] := floattostr(strtoint(mylist.Strings[count+1]) / strtoint(mylist.Strings[count+2])); ergebnis:= ergebnis + strtofloat(stringgrid.Cells[4,i+1]); count := count + 3; inc(i); //stringgrid.Cells[5, 13] := floattostr(strtoint(mylist.Strings[count+1]) + strtoint(mylist.Strings[count+2])); end; end; procedure TForm1.ButtonClick(Sender: TObject); begin stringgrid.Cells[4,14] := floattostr(ergebnis); Stringgrid.Cells[4,13] := 'Ergebnis'; end; procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var keineahnung: integer; begin if (ACol=4) and (StringGrid.Cells[ACol,ARow] <> '') then begin StringGrid.Canvas.Brush.Color := clYellow; if (ACol=4) and ((ARow = 13) or (ARow = 14)) then StringGrid.Canvas.Brush.Color := clRed; end; if (Stringgrid.Cells[acol,arow] <> '') and (TryStrToInt(StringGrid.Cells[ACol,ARow],keineahnung)) then begin if not (ACol=4) then begin if strtoint(Stringgrid.Cells[acol,arow]) <20 then StringGrid.Canvas.Brush.Color := clGreen; if strtoint(Stringgrid.Cells[acol,arow]) >20 then StringGrid.Canvas.Brush.Color := clBlue; if strtoint(Stringgrid.Cells[acol,arow]) <10 then StringGrid.Canvas.Brush.Color := clPurple; end; // if StrToBool(Stringgrid.Cells[acol,arow])=(StringGrid.Cells[ACol,ARow] <> '') then // StringGrid.Canvas.Brush.Color := clYellow; end; if (ACol > 0) and (ARow > 0) then begin StringGrid.Canvas.FillRect(Rect); StringGrid.Canvas.TextOut(Rect.Left, Rect.Top, StringGrid.Cells[ACol,ARow]); end; end; procedure TForm1.FormShow(Sender: TObject); begin // StringGrid.Cells[4,10] := 'text'; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:55 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