Solved

ListView and sorting items!

Posted on 2006-11-06
7
570 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…

789 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