Forum
Grundkurs
»Introduktion
»Snabbguide
»Komponenter
»Händelser
»Strängar
»Räkna med Delphi »Egna
typer
»Selektion
»Iteration
»Menyer
»Funktioner
»Arraystrukturer
Tips & Tricks
»Nya tips
»Blandat
»Databaser
»Filer
»Forms
»Grafik
»Internet
»Komponenter
»Matematik
»Multimedia
»Objekt/ActiveX
»Skrivare
»Strängar
»System
»Mest lästa tips
Artiklar
»Delphi och ADO
»Bygga en DLL
»Skapa en enkel rapport
»Hantera registret
»Enheter, units
»Klassen TCanvas
»Använd LookUp Controls
Nya
tips
Lägg
till tips
Delphilänkar
Gästbok
|
|
Redigera strängar i en textfil
|
Kategori: Filer
Inlagt: 2005-10-05
Läst: 1277
Inlagt av: Staffan Berg
|
Beskrivning |
Med hjälp av kombinationsrutor och textrutor kan du redigera önskade strängar i en textfil.
|
Kod |
//You can read the textfile into the combobox like this: ComboBox1.Items.LoadFromFile('c:\offers.txt'); ComboBox1.ItemIndex := 0; When an item is clicked: procedure TForm1.ComboBox1Click(Sender: TObject); var S: string ; P: integer; // position of separator begin S := ComboBox1.Items[ComboBox1.ItemIndex]; P := Pos(':', S); Edit1.Text := Copy(S, 1, P - 1); Edit2.Text := Copy(S, P + 1, Length(S) - P); end; //After modifying the edit-boxes, put item back at the same place: procedure TForm1.Button1Click(Sender: TObject); var N: integer; S: string ; begin N := ComboBox1.ItemIndex; S := Edit1.Text + ':' + Edit2.Text; ComboBox1.Items[N] := S; ComboBox1.ItemIndex := N; end; //At the end, save combobox items back to text file: ComboBox1.Items.SaveToFile('c:\offers.txt');
|
|
|