How can I change the position of new items at run-time?
Applies To: C++Builder 1 or higher
Category: Knowledge Base
- I can add new items using the Add method (as described in How can I add items at run-time?). Unfortunately, C++Builder inserts these new items at the end of the list. How can I specify the position where the new item will be inserted?
-

-
- Start a new project using File | New Application.
-
- Add a ListBox. Insert the items First and Third.
-
- Add a Button. Edit its OnClick event:
-
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- ListBox1->Items->Insert(1, "Second");
- }
-
- When you click on the button, the Second item will appear at the second position.
C++Builder Developer's Network
Copyright © Yoto Yotov