Главная страница | назад





Article #15518: IndexOf() in C++Builder

 Question and Answer Database
FAQ518C.txt IndexOf() in C++Builder
Category :VCL
Platform :All
Product :C++Builder 1.x
Question:
In Delphi, ListBox1.IndexOf(ListBox2.Items[i]) returns
the index in the first list box of the item specified
in the second.
In C++ Builder, this doesn't work, because Items is
a TString*, and IndexOf expects an AnsiString.
What do I do?
Answer:
You need to use:
ListBox1->Items->IndexOf(ListBox2->Items->Strings[i]);
There are two issues here. (1) IndexOf is a member of the
TStrings class, but not the TListBox class. (2) The Items
property of the TListBox contains a Strings property,
which is an array of TString.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99