Board index » delphi » "row" height in TList view

"row" height in TList view

In vsIcon mode:

I am trying to calculate the correct height of ListView.LargeImages that
will result in rows fitting in the display without showing a partial row on
the bottom.

Here is the code I am using now, which does not work:

procedure TListViewDisplay.SetCellSize(const Value: Integer);
begin
    FCellSize:= AutoSize(Value);
    with FListView.LargeImages do
    begin
      Width:= FCellSize;
      Height:= FCellSize;
    end;
    UpdateCount;
    //FListView.Invalidate;
end;

Then AutoSize() is:

function TListViewDisplay.AutoSize(DesiredSize: Integer): Integer;
var
  RowExtend: Integer;
  Rows: Integer;
  H: Integer;
begin
  // This does not work !!

  H:= FListView.ClientHeight;

  RowExtend:= H mod DesiredSize; // If the last row will be cut off
  if RowExtend > 0 then
  begin
    Rows:= H div DesiredSize; // number of rows that fit
    Inc(Rows); // Shrink.
    Result:= H div Rows; // size of one row
  end
  else
    Result:= DesiredSize;
end;

 

Re:"row" height in TList view


Seems to me that you are setting the height and widht of an imagelist in
setCellSize
which in turn will reset the imagelist and remove your images from it.

in AutoSize you are looking for the amount of rows?

so I think you logic needs a bit more work.

so are you looking for the amount of rows?
I think you have the correct code - obviously I have not tested it to death
I think you issue is in the setCellSize method.

--
Lawrence "Zen" Thurman
http://www.powerofzen.com

Re:"row" height in TList view


Quote
> Seems to me that you are setting the height and widht of an imagelist in
> setCellSize
> which in turn will reset the imagelist and remove your images from it.

I use custoim drawing:
  FListView.OwnerData:= True;
  FListView.OnCustomDrawItem:= ListViewCustomDrawItem;
  FListView.OnData:= ListViewData;

Quote
> in AutoSize you are looking for the amount of rows?

Yes, and then I am using this to calculate the cell size so that all visible
rows fit inside the list view without any visible rows being clipped.

I do not know the correct ImageList height to set because that height is
only part of the total height of the "row".

Quote
"Lawrence Thurman" <lthur...@columbus.rr.com> wrote in message

news:3d6d9edf$1@newsgroups.borland.com...
Quote
> Seems to me that you are setting the height and widht of an imagelist in
> setCellSize
> which in turn will reset the imagelist and remove your images from it.

> in AutoSize you are looking for the amount of rows?

> so I think you logic needs a bit more work.

> so are you looking for the amount of rows?
> I think you have the correct code - obviously I have not tested it to
death
> I think you issue is in the setCellSize method.

> --
> Lawrence "Zen" Thurman
> http://www.powerofzen.com

Other Threads