Board index » cppbuilder » ListBox->StringList->File

ListBox->StringList->File

Hi,

if I understood you right, you wanted to put the strings from
a TListBox to a TStringList and than the items from the
TStringList into a string, which you can store in a file. The
following code will do that.

   TStringList *tmpList = new TStringList;
   AnsiString s;

   tmpList->Assign(ListBox1->Items);

   for (int i = 0; i < tmpList->Count; i++)
      s = s + tmpList->Strings[i] + "\n";

   Label1->Caption = s;
   delete tmpList;
   tmpList = NULL;

Roman

 

Re:ListBox->StringList->File


thank you so much for your great help, it worked but unfortunally what comes
up from the ListBox are 2 Lines and I need only the second one .
Do you have a clue??
thx

Re:ListBox->StringList->File


Can't you just get the string out like this:

AnsiString Str;
Str = ListBox->Items->Strings[1];

/* Save Str to file however you want */
...

You don't need to loop over all the items in the ListBox.  Access the one
you want directly.

Quote
"J. Demensky" <is...@gmx.de> wrote in message

news:9in81p$cui$05$1@news.t-online.com...
Quote
> thank you so much for your great help, it worked but unfortunally what
comes
> up from the ListBox are 2 Lines and I need only the second one .
> Do you have a clue??
> thx

Other Threads