Solved

ListView and sorting items!

Posted on 2006-11-06
7
566 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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