Solved

How copy stringlist texts and objects into a listbox?

Posted on 2006-10-19
6
1,899 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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 386
Performance of SQL statement 37 143
JAudiorecorder record freezing the app 29 89
Delphi problems to abort a printjob 9 44
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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