Jump to content


Photo

BestFitRow(x, y) doesn't work as expected.


  • Please log in to reply
2 replies to this topic

#1 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 27 September 2016 - 11:55 PM

In v5 if I want the row to BestFitRow(i) it would assign the row height to that of the tallest column when wrapped.

 

In v6 if I set the column to WrapKind = wkWordWrap, and the column type is TNxTextColumn with data containing carriage return the field doesn't wrap.  Since it doesn't wrap, BestFitRow(x, y) doesn't work, where y is the column in question.

 

Am I missing something?

 

I've set the grid to AutoFit = True, FitOptions[foRow = True, foColumn = False], column VerticalAlignment = taAlignTop, and have tried setting the column to MultiLine = True, and changing to a different WrapKind but it's not working.

 

When I mouse over I see the hint, plus the white area (see screenshot) on some rows, but not others.

 

http://i.imgur.com/6YPde0o.jpg

 

This is how I'm adding data to the grid.

qry.Open;
grd.ClearRows;
while not qry.Eof do
begin
  grd.AddCells(
    ['False'
        ,qry.FieldByName('CustomerName').AsString
        ,qry.FieldByName('PrintNumber').AsString
        ,qry.FieldByName('GroupName').AsString
        ,qry.FieldByName('Age').AsString
        ,qry.FieldByName('TxnTime').AsString
        ,qry.FieldByName('ExpiresDate').AsString
        ,qry.FieldByName('InventoryNumber').AsString
        ,qry.FieldByName('CustomerId').AsString]
    ,[0,1,2,3,4,5,6,7,8]
  );
  grd.Cell[grd.Columns.ItemBy['InventoryNumber'].Index
    ,grd.LastAddedRow].Hint := qry.FieldByName('InventoryDesc').AsString;
  grd.BestFitRow(grd.LastAddedRow, grd.Columns.ItemBy['InventoryNumber'].Index);

  qry.Next;
end;

Thanks!



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,196 posts
  • Gender:Male

Posted 28 September 2016 - 01:25 AM

Hi,

It's a bug :( , try to replace next code in NxColumnViewClasses6 unit.
 
function TNxTextColumnView.GetBestSize: TSize;
begin
  Result := inherited GetBestSize;
  with Result do
  begin
    cx := GetTextWidth(Canvas, Column.GetDisplayText(Cell, Location.X, Location.Y), wkNone);
    cy := GetTextHeight(Canvas, Column.GetDisplayText(Cell, Location.X, Location.Y), Wrapable.WrapKind = wkWordWrap);
  end;
end;
Then use BestFit like this:

- Set column WrapKind to wkWordWrap (probably already is set).

Then use BestFitRow like this (omit second parameter).
 
NextGrid61.BestFitRow(RowIndex); 
In your case maybe you can set ShowTextFitHint to False for column.

ps. tell me if it worked to add it into official release.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 28 September 2016 - 04:00 PM

This worked.  Thank you.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users