Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:23:42+00:00 2026-06-04T18:23:42+00:00

I have a ListView with 3 columns and would like to edit the third

  • 0

I have a ListView with 3 columns and would like to edit the third column, aka Subitem[1]. If I set ListView.ReadOnly to False, it allows me to edit the caption of the selected item. Is there an easy way to do the same thing for the subitem? I would like to stay away from adding a borderless control on top that does the editing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:23:43+00:00Added an answer on June 4, 2026 at 6:23 pm

    You can Edit a subitem of the listview (in report mode) using a TEdit, a custom message and handling the OnClick event of the ListView.

    Try this sample

    Const
      USER_EDITLISTVIEW = WM_USER + 666;
    
    type
      TForm1 = class(TForm)
        ListView1: TListView;
        procedure FormCreate(Sender: TObject);
        procedure ListView1Click(Sender: TObject);
      private
        ListViewEditor: TEdit;
        LItem: TListitem;
        procedure UserEditListView( Var Message: TMessage ); message USER_EDITLISTVIEW;
        procedure ListViewEditorExit(Sender: TObject);
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses
      CommCtrl;
    const
      EDIT_COLUMN = 2; //Index of the column to Edit
    
    procedure TForm1.FormCreate(Sender: TObject);
    Var
      I : Integer;
      Item : TListItem;
    begin
      for I := 0 to 9 do
      begin
       Item:=ListView1.Items.Add;
       Item.Caption:=Format('%d.%d',[i,1]);
       Item.SubItems.Add(Format('%d.%d',[i,2]));
       Item.SubItems.Add(Format('%d.%d',[i,3]));
      end;
    
      //create the TEdit and assign the OnExit event
      ListViewEditor:=TEdit.Create(Self);
      ListViewEditor.Parent:=ListView1;
      ListViewEditor.OnExit:=ListViewEditorExit;
      ListViewEditor.Visible:=False;
    end;
    
    procedure TForm1.ListView1Click(Sender: TObject);
    var
      LPoint: TPoint;
      LVHitTestInfo: TLVHitTestInfo;
    begin
      LPoint:= listview1.ScreenToClient(Mouse.CursorPos);
      ZeroMemory( @LVHitTestInfo, SizeOf(LVHitTestInfo));
      LVHitTestInfo.pt := LPoint;
      //Check if the click was made in the column to edit
      If (ListView1.perform( LVM_SUBITEMHITTEST, 0, LPARAM(@LVHitTestInfo))<>-1) and ( LVHitTestInfo.iSubItem = EDIT_COLUMN ) Then
        PostMessage( self.Handle, USER_EDITLISTVIEW, LVHitTestInfo.iItem, 0 )
      else
        ListViewEditor.Visible:=False; //hide the TEdit 
    end;
    
    procedure TForm1.ListViewEditorExit(Sender: TObject);
    begin
      If Assigned(LItem) Then
      Begin
        //assign the vslue of the TEdit to the Subitem
        LItem.SubItems[ EDIT_COLUMN-1 ] := ListViewEditor.Text;
        LItem := nil;
      End;
    end;
    
    procedure TForm1.UserEditListView(var Message: TMessage);
    var
      LRect: TRect;
    begin
      LRect.Top := EDIT_COLUMN;
      LRect.Left:= LVIR_BOUNDS;
      listview1.Perform( LVM_GETSUBITEMRECT, Message.wparam,  LPARAM(@LRect) );
      MapWindowPoints( listview1.Handle, ListViewEditor.Parent.Handle, LRect, 2 );
      //get the current Item to edit
      LItem := listview1.Items[ Message.wparam ];
      //set the text of the Edit 
      ListViewEditor.Text := LItem.Subitems[ EDIT_COLUMN-1];
      //set the bounds of the TEdit
      ListViewEditor.BoundsRect := LRect; 
      //Show the TEdit
      ListViewEditor.Visible:=True;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView with a GridView with 3 columns. I want last column
I have a ListView control set up in details mode with 5 columns. It
I have a ListView Contained in a UserControl I would like to disabled a
I have a listview with 2 columns. I can easily populate the first column
I have a listview in Details view and I have added columns. I would
I have an application with a ListView ('SysListView32') control, from which I would like
I have a listview and i would like to populate a row with several
I have ListView that uses a GridView to display several columns of data. Two
I have a listview in c# with three columns and the view is details.
Background: I have a ListView / GridView with several columns. In some situations, only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.