--> Edit the data items in TListView Column by Delphi | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

Edit the data items in TListView Column by Delphi

| Tuesday, 15 November 2011


The following tricks easier for you to edit / update data items in TListView column with viewStyle: = vsReport.

Declaration procedure:
EditItemListView procedure (LV: TListView; Row, Col: Integer; Datane: String);
begin
   if Col> LV.Columns.Count then Exit;
   do with LV
   begin
     if (Col <= 1) then
       Items.Item [Row]. Caption: = Datane
     else
       Items.Item [Row]. SubItems.Strings [Col -2]: = Datane;
   end;
end;

For property parameters (LV, Row, Col) as String Reading in Sub-Item ListView (ViewStyle = vsReport). For the parameters of a new data replacement Datane previous data.

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
   with ListView1 do
   begin
     EditItemListView (ListView1, Selected.Index, 1, Edit1.Text);
     EditItemListView (ListView1, Selected.Index, 2, Edit2.Text);
     EditItemListView (ListView1, Selected.Index, 3, Edit3.Text);
   end;
end;

Related Posts

No comments: