Solved

ListView and sorting items!

Posted on 2006-11-06
7
573 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 63 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
Industry Leaders: 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 62 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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