Help needed with code (ListView)

Posted on 2007-10-17
Last Modified: 2010-04-04
Hi experts,

I need some help with code.

I am using the following:

var i: integer;
  for i := 0 to listView1.Items.Count-1 do
    listView1.Items[i].Caption :=('hello');

Right now this code add "hello" to every field on cloumn 0

I need to create a new header name instead and then add "hello" to each field in the new column.

Hope you can help



Question by:ST3VO
    LVL 19

    Expert Comment

    does this column have to be the first one?

    Author Comment

    No...I actually would prefare it to be the after the last column!

    LVL 19

    Accepted Solution

    pfew, that saves a lot of work:

    procedure TForm1.Button1Click(Sender: TObject);
    var NewColumn: TListColumn;
        i: integer;
     NewColumn := ListView1.Columns.Add();
     NewColumn.Caption := 'new column';
     NewColumn.Width := 100;
     // set more properties for the column if you want

     for i := 0 to ListView1.Items.Count - 1 do
    LVL 19

    Expert Comment

    be aware though, if you want to shuffle around with columns TListView is not a very good component to use!

    Author Comment

    Perfect as usual! Thanks!!! :o)

    Ref: TListView and Columns I am actually using TAdvListView (TMS) I just thought I'd post as TListView as the code is compatible on AdvListView too and I would get faster response posting the question as TListView than TAdvListView.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    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…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now