Board index » delphi » Assigning a Pointer to TStringList.Items to ListBox Items
Raymond Kennington
![]() Delphi Developer |
Thu, 29 Apr 2004 07:08:07 GMT
|
Raymond Kennington
![]() Delphi Developer |
Thu, 29 Apr 2004 07:08:07 GMT
Assigning a Pointer to TStringList.Items to ListBox Items
I want to assigning a pointer to a TStringList.Items array to ListBox.Items array without copying the items.
Is it possible to make one items array point to another with the idea of refreshing the listbox after making the Items property point to a different If so, how? Thanks. |
Team
![]() Delphi Developer |
Thu, 29 Apr 2004 18:01:13 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsQuoteIn article <3BEDB357.C3F6...@chariot.net.au>, Raymond Kennington wrote: control and the latter actually manages the strings. It is quite easy though: ListBox.Items.Assign(StringList); Mike Orriss (TeamB and DevExpress) |
Raymond Kenningto
![]() Delphi Developer |
Thu, 29 Apr 2004 19:32:50 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsThanks. Suppose there are 100 StringLists with 2000 strings with Objects (that use lots of memory) attached to each string. I don't want to copy the objects. Suppose further that these StringLists are to appear on the screen in a single ListBox one list at a time. The ListBox manages insertions and So it looks like I'll have to have 100 listBoxes and display each one in turn instead. Is there a better way? Raymond. |
Team
![]() Delphi Developer |
Thu, 29 Apr 2004 20:17:12 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsQuoteIn article <3BEDB357.C3F6...@chariot.net.au>, Raymond Kennington wrote: standard Windows control. The listbox control stores the strings it displays internally (in Windows code), the Items property just gives you Tstrings-style access to these internally stored items, it does not have any VCl-level storage space for the items. Quote
class has support for this mode build in. Look at the OnData event in the online help. You can use this mode to tie the listbox to an external list of strings. You would still have to do some things to get the listbox to repaint if an item changes in the external list since the listbox has no way of getting aware of such a change. Example for using a TListbox in virtual mode: Create a new application, drop a Tedit, TLIstbox, 3 TButtons, 1 TActionlist unit Unit1; interface uses type var implementation {$R *.dfm} procedure TForm1.AddActionUpdate(Sender: TObject); procedure TForm1.AddActionExecute(Sender: TObject); procedure TForm1.FormCreate(Sender: TObject); Procedure TForm1.TextItemsChange(sender: TObject); procedure TForm1.FormDestroy(Sender: TObject); procedure TForm1.DeleteActionUpdate(Sender: TObject); procedure TForm1.DeleteActionExecute(Sender: TObject); procedure TForm1.ReplaceActionUpdate(Sender: TObject); procedure TForm1.ReplaceActionExecute(Sender: TObject); procedure TForm1.ListBox1Data(Control: TWinControl; Index: Integer; function TForm1.ListBox1DataFind(Control: TWinControl; end. Here is the finished form DFM file: object Form1: TForm1 Peter Below (TeamB) 100113.1...@compuserve.com) |
Team
![]() Delphi Developer |
Thu, 29 Apr 2004 22:48:09 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsQuoteIn article <3BEE61E2.B2428...@chariot.net.au>, Raymond Kennington wrote: presenting the user with 100 listboxes one after another sounds very heavy. Mike Orriss (TeamB and DevExpress) |
Raymond Kenningto
![]() Delphi Developer |
Fri, 30 Apr 2004 11:28:47 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsThere will be lots in memory and the user will be able to choose which list is displayed in the listbox. The user could choose to show N lists at a time. Since each item in each list will contain an object of maybe 3 Kb it seemed like a good idea not to continually swap the lists from internal memory to So now I think I'll create as many list boxes as required and hide/show them by setting the parent to nil or a windowControl (yet to be decided which Will having 100 ListBoxes in memory overload Win95's resources? Or memory? Raymond Kennington. Quote"Mike Orriss (TeamB)" wrote: |
Team
![]() Delphi Developer |
Fri, 30 Apr 2004 18:25:36 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsQuoteIn article <3BEF41EF.F1EE0...@chariot.net.au>, Raymond Kennington wrote: Why do all listboxes need to be created first? Can't you create and destroy Mike Orriss (TeamB and DevExpress) |
Wood
![]() Delphi Developer |
Sat, 01 May 2004 01:32:03 GMT
Re:Assigning a Pointer to TStringList.Items to ListBox ItemsQuote"Raymond Kennington" <raymo...@chariot.net.au> wrote in message Quote> There will be lots in memory and the user will be able to choose which Quote> time. memory to Quote> a list box. which Quote> one). the variations and just use one listbox to assign them to? Woody |
1. How to avoid deselecting item when ListBox.Items.Exchange
2. Listbox with items and pointers?
3. Items[0].Items[0].Items[0]...
4. Accessing ListBox.Items.Objects on ListBox's events
5. Address to a Tstringlist item
6. Help: TListBox.Items.IndexOf() slower then TStringList.IndexOf() ????
7. ListView => items.item[?].caption question
8. popup menu on items of a listview and not if no item selected
9. Why is the first item = Item[0]
10. search items of listbox1 that are not equal to the items of listbox2