Board index » delphi » File data to ComboBox.Items.Add

File data to ComboBox.Items.Add

Hello all,

Would someone please explain the procedure for reading a text file into
ComboBox.Items and then saving to the same file if ComboBox.Items.Add was
executed? I've only got two books on Delphi and can't seem to find what
I'm looking for. Thanks!

 

Re:File data to ComboBox.Items.Add


Quote
cynique wrote:

> Hello all,

> Would someone please explain the procedure for reading a text file into
> ComboBox.Items and then saving to the same file if ComboBox.Items.Add was
> executed? I've only got two books on Delphi and can't seem to find what
> I'm looking for. Thanks!

ComboBox.Items.LoadFromFile('myfile.txt');
ComboBox.Items.SaveToFile('myfile.txt');

Alex
--
** Pepsi Cola and Animal protection **
**  http://www.pepsi{*word*76}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://pino.cjb.net

Re:File data to ComboBox.Items.Add


Quote
On Thu, 18 Nov 1999 10:38:06 -0800, cynique <cyni...@earthlink.net> wrote:
>Would someone please explain the procedure for reading a text file into
>ComboBox.Items and then saving to the same file if ComboBox.Items.Add was
>executed? I've only got two books on Delphi and can't seem to find what
>I'm looking for. Thanks!

String list objects (of which the TComboBox.Items property is one) have
LoadFromFile and SaveToFile methods. These methods do exactly what you ask.

Properly loading the data from text file to TComboBox does require the
incoming data be in a specific format, though. One item per line, each line
terminated with a CR and LF, and no spaces on the left side of the values.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

Other Threads