Adding a button to certain items of TListView lazarus / 31-LCL ---------------------------------------------------------------------- blankname · 2022-01-03 14:11 Is there any way of adding a button to certain items of TListView? I'd like to add one or two buttons to items with specific data. I've been searching on the internet, and found that Delphi 10.1 offers such thing with ItemAppearance, but Lazarus does not have it... ---------------------------------------------------------------------- wp · 2022-01-03 15:21 I don't know of this possibility (but of course, this does not mean anything...). I'd switch to a TStringGrid which can be set up to look very similar to a TListView in report mode. Or I'd use TVirtualTreeView which can be set to a grid/listview-like appearance - this will require some major changes within your application though. ---------------------------------------------------------------------- balazsszekely · 2022-01-03 15:50 What is ViewStyle? vsReport?  If yes, then you can try something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses LCLIntf, LCLType; type  PData = ^TData;  TData = record     Text: String[255];    //add other variables if needed    Button: TButton;  end; procedure TForm1.FormCreate(Sender: TObject);var  Data: PData;  ListItem: TListItem;begin  //add item with button  GetMem(Data, SizeOf(TData));  Data^.Button := TButton.Create(nil);  Data^.Button.Caption := "Click me!!!";  ListItem := ListView1.Items.Add;  ListItem.Caption := "line1";  ListItem.Data := Data;   //add item without button  Data := nil;  ListItem := ListView1.Items.Add;  ListItem.Caption := "line2";  ListItem.Subitems.Add("no button");  ListItem.Data := Data;end; procedure TForm1.FormDestroy(Sender: TObject);var  Data: PData;  I: Integer;begin  for I := ListView1.Items.Count - 1 downto 0 do  begin    Data := ListView1.Items.Item[I].Data;    if Data <> nil then    begin      Data^.Button.Free;      Freemem(Data);    end;    ListView1.Items.Delete(I);  end;end; procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;  Item: TListItem; SubItem: Integer; State: TCustomDrawState;  var DefaultDraw: Boolean);var  R: TRect;  Data: PData;begin  Data := Item.Data;  if Data = nil then  begin    DefaultDraw := True;    Exit;  end;   DefaultDraw := False;  R := Item.DisplayRectSubItem(1, drBounds);  InflateRect(R, -1, -1);  Data^.Button.Parent := ListView1;  Data^.Button.SetBounds(R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top);  Data^.Button.OnClick := @DoOnButtonClick;end; procedure TForm1.DoOnButtonClick(Sender: TObject);begin  ShowMessage("Boom!!!");end; ---------------------------------------------------------------------- pcurtis · 2022-02-12 12:11 @getmem Just what I'm looking for. How can I add an extra column also with a button?