Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase row height of listview in report style?

I need to add just 2px :) to a height of a row in a list view (a custom drawn progress bar is too narrow now).

There are two good answers Change Listview item height, http://www.delphipages.com/forum/showthread.php?t=49939, but I couldn't do it.

I know that it is possible to do with an image list, but I have already 16x16 images :)

Can anybody help me? I'll appreciate it.

like image 940
maxfax Avatar asked Aug 15 '11 00:08

maxfax


2 Answers

Respond to the CN_MEASUREITEM control notification message, as follows:

type
  TListView = class(ComCtrls.TListView)
  private
    procedure CNMeasureItem(var Message: TWMMeasureItem); message CN_MEASUREITEM;
  end;

  TForm1 = class(TForm)
    ...

procedure TListView.CNMeasureItem(var Message: TWMMeasureItem);
begin
  inherited;
  Inc(Message.MeasureItemStruct.itemHeight, 2);
end;

Note: this message will only be send if the OwnerDraw property is true.

like image 65
NGLN Avatar answered Sep 22 '22 12:09

NGLN


A quick and dirty alternative without writing any code would be to add a TImageList, set its width to 1 and its height to whatever you want the lines height to be and assign it to the SmallImages of the listview.

like image 21
CodeX Avatar answered Sep 21 '22 12:09

CodeX