Not every component allows you to add objects to their “elements”. Since I too have struggled with this in the past, I figured: why not write a small article about that. They all expect a TObject, and that’s the part that can be a little confusing at times. This is exactly where the function “ AddObject” and “ InsertObject” and the property “ Objects” come in handy … but how do we use them? You could of course maintain a separate list or array with your additional data in it, but you’d have to keep it in sync, which can be a pain at times, causing extra work and problems. However, you’d like to “link” additional data to these individual “names”, but you do not wish the additional information to be in your “list”. It might not happen often, but you could find yourself in a situation where you want to display, for example, a list of names. Delete (newItemIndex ) įor Counter : = 0 to ListBox1. ShowMessage ( 'SomeNumber: ' + IntToStr ( TM圜lass (ListBox1. Add object and string item to the list Procedure Button1Click (Sender : TObject ) Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls ,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |