Solved

ListView and sorting items!

Posted on 2006-11-06
7
567 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 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

17 Experts available now in Live!

Get 1:1 Help Now