Solved

How copy stringlist texts and objects into a listbox?

Posted on 2006-10-19
6
1,818 Views
Last Modified: 2008-02-01
Hi
I'm learning Delphi.
This must be easy.
I have a stringlist filled with rows of text. Each row has an object associated with it.
How do I copy each row's text and object into a listbox?

0
Comment
Question by:tiggermark
6 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 17764443
Listobox1.Items.Assign(stringlist.lines);

ziolko.
0
 
LVL 15

Assisted Solution

by:mikelittlewood
mikelittlewood earned 50 total points
ID: 17764490
Dont need the lines

Listobox1.Items.Assign( Stringlist);
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 50 total points
ID: 17764503
if you don't want to loose previous content of the listbox you can use AddStrings
Listbox1.Items.AddStrings(StringList);
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:tiggermark
ID: 17765883
Thanks guys, especially mikelittlewood.

Sorry for delay replying. Had to leave the desk and do something else.

For some reason I thought I had to assign each line in a loop using .count and [index].

MerijnB: doesn't AddStrings simply add the strings and not the objects?

Mark
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 17766154
nope, from classes.pas:

procedure TStrings.AddStrings(Strings: TStrings);
var
  I: Integer;
begin
  BeginUpdate;
  try
    for I := 0 to Strings.Count - 1 do
      AddObject(Strings[I], Strings.Objects[I]);
  finally
    EndUpdate;
  end;
end;
0
 

Author Comment

by:tiggermark
ID: 17767307
Upped the points and split them (I hope) between mikelittlewood and MerijnB.

Thanks. Both comments highly useful.

Mark
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 260
Magic Software info 18 130
select query - oracle 16 100
Installshield for Embarcadero EX 10.1 Berlin 4 37
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now