Posted by Johan on April 04, 2005
In Reply to: Editing strings in a file using pointers? posted
by Scott I think it's easier if you use a text file to save offernames and discounts, 1 per line, like this: 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'); Related Articles and Replies
|