This post about listing String and displaying methods as fast as possible in Modern C++, in C++ Builder FireMonkey projects. In general if you have many String additions to you component, you must use BeginUpdate() and EndUpdate() methods of that Class member to do these operations faster. In normal way most of Components are also doing this addition method faster.
Table of Contents
Memo and StringLists (TStringList)
We can directly copy list of unicode strings by using TStringList. We need to use BeginUpdate() and EndUpdate() methods over this TStringList and add all lines to Memo1 to display
1 2 3 4 5 6 7 8 9 10 11 12 13 |
TStringList *strl=new(TStringList); strl->BeginUpdate(); for(int i=0; i<1000; i++) { strl->Add("Testing"); } strl->EndUpdate(); // lets add all strings to Memo Memo1->Lines->Add(str1->Text); strl->Free(); |
Memo
We can use Memo to display lines directly. TMemo is a multiline text editing control, providing text scrolling. If you want to update all faster, use BeginUpdate() and EndUpdate() methods as same above.
1 2 3 4 5 6 7 8 |
Memo1->Lines->BeginUpdate(); for(int i=0; i<1000; i++) { Memo1->Lines->Add("Testing"); } Memo1->Lines->EndUpdate(); |
ListBox
A TListBox displays a set of items in a scrollable list.
1 2 3 4 5 6 7 8 |
ListBox1->BeginUpdate(); for(int i=0; i<1000; i++) { ListBox1->Items->Add("Testing"); } ListBox1->EndUpdate(); |
ListView
TListView displays a collection of items in a list that is optimized for LiveBindings and for fast and smooth scrolling.
1 2 3 4 5 6 7 8 9 10 11 |
TListViewItem *TI; ListView1->BeginUpdate(); for(int i=0; i<1000; i++) { TI = ListView1->Items->Add(); TI->Text="abcdefghijkl"; } ListView1->EndUpdate(); |
StringGrid
TStringGrid represents a grid control like Xxcel tables, designed to simplify the handling of strings. We can use this grid to display strings or numbers converting to String by using IntoToStr() or FloatToStr() functions.
1 2 3 4 5 6 7 8 9 10 |
StringGrid1->RowCount=1002; StringGrid1->BeginUpdate(); for(int i=0; i<1000; i++) { StringGrid1->Cells[0][i]="Testing"; } StringGrid1->EndUpdate(); |
As in these examples you can update and display your different kind of variables very fast in these components. They have different benefits while most are same in speed to add your variables.