Autor |
Beitrag |
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Mo 19.03.18 21:27
Delphi-Quelltext 1:
| s := SplitString(StringGrid1.Cells[StringGrid1.Col + 1, StringGrid1.Row], ' '); |
Beim Kompilieren meckert er "SplitString" an
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mo 19.03.18 21:53
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Mo 19.03.18 22:20
ist drin.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149:
| unit Unit1;
interface
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Types, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls, Vcl.ComCtrls;
type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Edit1: TEdit; StringGrid1: TStringGrid; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure StringGrid1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure SaveStringGridToFile(StringGrid: TStringGrid; const FileName: String); var F: TStringList; i: Integer; begin F := TStringList.Create; try F.Add(IntToStr(StringGrid.RowCount)); F.Add(IntToStr(StringGrid.ColCount)); for i := 0 to (StringGrid.RowCount - 1) do F.Add(StringGrid.Rows[i].CommaText); F.SaveToFile(FileName); finally F.Free; end; end;
procedure TForm1.Button2Click(Sender: TObject); begin SaveStringGridToFile(StringGrid1, '.\daten.dat'); end;
procedure LoadStringGridFromFile(StringGrid: TStringGrid; const FileName: String); var F: TStringList; i: Integer; begin F := TStringList.Create; try F.LoadFromFile(FileName); StringGrid.RowCount := StrToInt(F[0]); StringGrid.ColCount := StrToInt(F[1]); for i := 0 to (StringGrid.RowCount - 1) do StringGrid.Rows[i].CommaText := F[i + 2]; finally F.Free; end; end;
procedure TForm1.Button3Click(Sender: TObject); begin if FileExists('.\daten.dat') then LoadStringGridFromFile(StringGrid1, '.\daten.dat'); end;
procedure TForm1.FormCreate(Sender: TObject); begin Edit1.Clear; Memo1.Clear; end;
procedure TForm1.Button1Click(Sender: TObject); var s: string; begin StringGrid1.RowCount := StringGrid1.RowCount + 1; StringGrid1.Cols[0].Add(Trim(Edit1.Text)).Size; StringGrid1.Cols[1].Add(Memo1.Lines.Text.Replace(sLineBreak, ' ')); Edit1.Clear; Memo1.Clear; Edit1.SetFocus; end;
procedure TForm1.StringGrid1Click(Sender: TObject); var s: TStringDynArray; i: Integer; begin if StringGrid1.Col = 0 then begin Edit1.Clear; Memo1.Clear; Edit1.Text := StringGrid1.Cells[StringGrid1.Col, StringGrid1.Row];; s := SplitString(StringGrid1.Cells[StringGrid1.Col + 1, StringGrid1.Row], ' '); for i := 0 to Length(s) - 1 do Memo1.Lines.Add(s[i]); end; SendMessage(Memo1.Handle, WM_VSCROLL, SB_TOP, 0); end;
end. |
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mo 19.03.18 23:35
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Mo 19.03.18 23:52
ok, jetzt kein fehler. aber immer noch nicht so wie es sein sollte ;(
Einloggen, um Attachments anzusehen!
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Mo 19.03.18 23:54
Delphi-Quelltext 1:
| StringGrid1.Cols[1].Add(Memo1.Lines.Text.Replace(sLineBreak, ' ')); |
kann man nicht ein CR + LF eingeben? Ich weiß das ein String zurück gegeben wird. Aber wie kann man es anders realisieren?
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 20.03.18 00:08
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Di 20.03.18 00:14
danke aber das du die geduld hattest
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 20.03.18 00:18
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Di 20.03.18 00:26
danke dir,
das wäre eine alternative.
aber in dem memo können auch zeichen wie das komma drin vorkommen.
dann würde es automatisch ein zeilenumbruch machen.
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 20.03.18 00:32
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Di 20.03.18 00:37
wie kann man es ganz anders aufbauen damit der text im memo 1:1 übergeben wird und dann auch wieder so geladen wird.
vielleicht kein StringGrid? Vielleicht eine andere Komponennte?
Zuletzt bearbeitet von drache999 am Di 20.03.18 00:41, insgesamt 1-mal bearbeitet
|
|
drache999 ![Threadstarter Threadstarter](./graphics/viewtopic/threadstarter.png)
![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![drache999 hat insgesamt 100.0% On-Topic und 0.0% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 18
|
Verfasst: Di 20.03.18 00:40
ich habe ein "#" eingepflegt. Das wird bestimmt nicht im Memo vorkommen. Und somit funktioniert es !
Ich danke dir vielmals! ![:)](images/smiles/icon_smile.gif)
|
|
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 20.03.18 00:49
- Nachträglich durch die Entwickler-Ecke gelöscht -
|
|
Sinspin
![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png) ![Sinspin hat insgesamt 85.6% On-Topic und 14.4% Off-Topic Beiträge geschrieben. ontopic star](./graphics/ranks/star_ontopic_full.png)
Beiträge: 1322
Erhaltene Danke: 117
Win 10
RIO, CE, Lazarus
|
Verfasst: Di 20.03.18 08:58
Hey, bevor Du dich selber damit rumärgerst das zu implementieren, die TStringList unterstützt das CSV Format.
Dafür weist Du der Eigenschaft CommaText einen String zu oder ließt ihn aus. Jeder Eintrag in der StringList entspricht dann einer Spalte einer Zeile in deiner Tabelle.
Dabei ist es egal ob der Text Kommas, Punkte oder andere Sonderzeichen enthält.
Mit einer zweiten TStringList kannst Du die einzelnen Zeilen deiner Tabelle dann einfach laden und speichern.
_________________ Wir zerstören die Natur und Wälder der Erde. Wir töten wilde Tiere für Trophäen. Wir produzieren Lebewesen als Massenware um sie nach wenigen Monaten zu töten. Warum sollte unser aller Mutter, die Natur, nicht die gleichen Rechte haben?
|
|