?
Solved

ListView and sorting items!

Posted on 2006-11-06
7
Medium Priority
?
574 Views
Last Modified: 2008-03-15
I got a big problem with a listview I been trying to add more then one name to it and all I get is one big line of names like so

SimonSteveMark

how can I split it up so when it reads all the names from the server it adds them correct like so

Simon
Steve
Mark!

allso how would I be able to read each item so I can check the list from other location like this

dat[17] = listview.caption; ( just a demo )

anyone???
0
Comment
Question by:fiveuk
[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
7 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 252 total points
ID: 17880419
Dear Fiveuk,

you can use something like this :
initilize i with 0;
   i :integer= 0;

on button click add this :

   ListView.Items.Add;
   ListView.Items.Item[i].Caption := Edit1.Text;   //   "i" represent the row number.
   inc(i);


to retrieve the data :

   dat[17] := ListView.Items.Item[i].Caption;   //   "i" represent the row that you want to asign in dat[17]


Regards.
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17885076
adding items to a listview is done like this:-

var
  newitem: TListitem;
begin
  ListView1.ViewStyle := vsreport; // set the display to show columns and rows for items
  newitem := ListView1.Items.Add;
  newitem.caption := edit1.text;
end;
0
 

Author Comment

by:fiveuk
ID: 17920823
ok dont work the problem is a am getting a list of names from a server

as one text format simon, steve so on but I want the listview to add each name as a new item(caption) how can I do this?
0
Independent Software Vendors: 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!

 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 248 total points
ID: 17923967
when you say a list, do you mean 'simon,steve,bob'
or do you mean something else?
if it is 'simon,steve,bob' then you can do something like

procedure TForm1.PutNamesIntoListView(s: string);
var
  sl: TStringList;
  newitem: TListitem;
  i: integer;
begin
  sl := TStringList.Create;
  try
    sl.Text := StringReplace(s, ',', #13#10, [rfReplaceAll]); // convert commas to CR/LF so it becomes a list in the StringList
    for i := 0 to pred(sl.count) do
    begin
      s := sl[i];
      if s <> '' then
      begin
        newitem := ListView1.Items.Add;
        newitem.caption := edit1.text;
      end;
    end;
  finally
    sl.free;
  end;
0
 

Expert Comment

by:caydangcothu05
ID: 17924134
I think TheRealLoki has right, except that you want to advertise for server in your question
regards,
caydangcothu05
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133167
Forced accept.

Computer101
EE Admin
0

Featured Post

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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 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