There is a procedure for writing to the ListBox1.Items.SaveToFile('notes.txt'); file ListBox1.Items.SaveToFile('notes.txt');
Its output is ListBox1.Items.LoadFromFile('notes.txt');
But how to delete a string directly in notes.txt?
Download. Delete. Save.
How to remove:
ListBox1.Items.Delete(42); // удалит 43 строку (нумерация идет с 0) ListBox1.DeleteSelected; // удалит выбранную(ые) строки в ListBox1 Total:
ListBox1.Items.LoadFromFile('notes.txt'); ListBox1.Items.Delete(42); ListBox1.DeleteSelected; ListBox1.Items.SaveToFile('notes.txt'); If you need to delete without ListBox1, then use TStringList, for example.
procedure DeleteLine(const aPath: string; aLineToDelete: Integer); var // Локальная переменная вместо with, во избежании путаницы SL: TStringList; begin SL := TStringList.Create; try SL.LoadFromFile(aPath); SL.Delete(aLineToDelete); SL.SaveToFile(aPath); finally SL.Free; end; end; ListBox1.Items.Delete(42) - ListBox1.Items.DeleteSelected - NickGromTListBox , but not TListBox.Items - KromsterSource: https://ru.stackoverflow.com/questions/776581/
All Articles