![]() |
AW: StringGrid Spalte kopieren
oh....
ob Dich das weiter bringt? :-)
Delphi-Quellcode:
unit Unit1;
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls, Vcl.ExtCtrls, Filectrl; type TForm1 = class(TForm) StringGrid1: TStringGrid; Panel1: TPanel; Edit1: TEdit; Edit2: TEdit; Panel2: TPanel; Button1: TButton; Label1: TLabel; Label2: TLabel; Button2: TButton; CheckBox1: TCheckBox; Edit3: TEdit; Label3: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure Button2Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; zaehler: integer = 0; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var SearchRec: TSearchRec; i,k:integer; begin FindFirst(ExtractFilePath(Edit1.Text) + '*.asc', faAnyFile, SearchRec); // '\\192.168.0.62\d$\Office\TESTDATEN\' repeat until FindNext(searchrec) <> 0; findclose(searchrec); with StringGrid1 do for i := 0 to ColCount - 1 do for k := 0 to RowCount - 1 do Cells[i, k] := ''; StringGrid1.RowCount := 1; FindFirst(ExtractFilePath(Edit1.Text) + '*.asc', faAnyFile, SearchRec); repeat StringGrid1.RowCount := StringGrid1.RowCount + 1; for i := StringGrid1.RowCount - 1 downto StringGrid1.FixedRows + 1 do StringGrid1.Rows [i].Assign (StringGrid1.Rows [i - 1]); inc(zaehler); Edit3.Text :=(FormatDateTime('yymmdd',now)+(Format('%.4d',[zaehler]))); StringGrid1.Cells[1,0]:='date'; StringGrid1.Cells[2,0]:='time'; StringGrid1.Cells[3,0]:='event'; StringGrid1.Cells[4,0]:='id leitstelle-mk'; StringGrid1.Cells[5,0]:='id mp-feuer'; StringGrid1.Cells[6,0]:='event icon'; Stringgrid1.Cells[4,1]:=(searchrec.Name); StringGrid1.Cells[3,1] := 'read datafile'; Stringgrid1.Cells[1,1]:=(FormatDateTime('dd.mm.yy',now)); StringGrid1.Cells[2,1] :=(FormatDateTime('hh:nn:ss',now)); Stringgrid1.Cells[5,1]:= Edit3.Text; Stringgrid1.Cells[6,1]:=''; StringGrid1.Selection := TGridRect(Rect(StringGrid1.FixedCols,1,StringGrid1.ColCount-1,1)); until FindNext(searchrec) <> 0; findclose(searchrec); end; procedure TForm1.Button2Click(Sender: TObject); var List: TStrings; begin List := TStringList.Create; try List.Add(Edit1.Text); List.Add(Edit2.Text); List.Add(Edit3.Text); List.SaveToFile('ExtractFilePath(ParamStr(0))'+'setting.dat'); finally List.Free; end; end; procedure TForm1.FormActivate(Sender: TObject); var i,j :integer; List: TStringList; begin for i := stringgrid1.FixedCols to stringgrid1.ColCount - 1 do begin for j :=stringgrid1.FixedRows to stringgrid1.RowCount - 1 do begin stringgrid1.Cells[i,j] := ''; end; end; stringgrid1.rowCount := stringgrid1.Fixedrows +1; StringGrid1.Cells [1,1] := FormatDateTime ('dd.mm.yy', Now); StringGrid1.Cells [2,1] := FormatDateTime ('hh:nn:ss', Now); StringGrid1.Cells [3,1] := 'load file'; StringGrid1.Cells [4,1] := 'not specified'; StringGrid1.Cells [5,1] := 'not specified'; List := TStringList.Create; try List.LoadFromFile('ExtractFilePath(ParamStr(0))'+'setting.dat'); if List.Count>0 then Edit1.Text:=List[0]; Edit2.Text:=List[1]; Edit3.Text:=List[2]; finally List.Free; end; end; procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var List: TStrings; begin List := TStringList.Create; try List.Add(Edit1.Text); List.Add(Edit2.Text); List.Add(Edit3.Text); List.SaveToFile('ExtractFilePath(ParamStr(0))'+'setting.dat'); finally List.Free; end; end; procedure TForm1.FormCreate(Sender: TObject); begin StringGrid1.Cells[1,0]:='date'; StringGrid1.Cells[2,0]:='time'; StringGrid1.Cells[3,0]:='event'; StringGrid1.Cells[4,0]:='id leitstelle-mk'; StringGrid1.Cells[5,0]:='id mp-feuer'; StringGrid1.Cells[6,0]:='event icon'; StringGrid1.ColWidths[0] := -1; Stringgrid1.ColWidths[1] := 70; Stringgrid1.ColWidths[2] := 70; Stringgrid1.ColWidths[3] := 80; Stringgrid1.ColWidths[4] := 140; Stringgrid1.ColWidths[5] := 140; Stringgrid1.ColWidths[6] := 70; //Edit1.Text := '\\192.168.0.62\d$\Office\TESTDATEN\'; //Edit2.Text := '\\192.168.0.62\d$\Office\TESTDATEN\'; Edit3.Clear; end; procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin CanSelect := (StringGrid1.Cells[ACol, ARow]='') end; end. |
AW: StringGrid Spalte kopieren
Delphi-Quellcode:
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin // Kopiert den Zellinhalt der zweiten Spalte der aktuellen Zeile ins Editfeld Edit2.Text := Stringgrid1.Cells[2,Stringgrid1.Row]; end; |
AW: StringGrid Spalte kopieren
Moin...:P
Spielverderber...8-) |
AW: StringGrid Spalte kopieren
Bevor man jemanden auf den Holzweg schickt, tipp ich die richtige Lösung auch mit einem Finger :P
|
AW: StringGrid Spalte kopieren
Aber nicht, solange die Beschriftung der F1-Taste auf seiner Tastatur noch zu erkennen ist :mrgreen:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:37 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