Spread Windows Forms 11.0 Product Documentation
GetPreferredRowHeight Method


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class : GetPreferredRowHeight Method
Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.
Gets the height of the tallest text string in the specified row on the sheet.
Overload List
OverloadDescription
Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
Remarks

Row heights can be based on the data in the cells using this method or the Row.GetPreferredHeight method. For more information, see Resizing the Row and Column to Fit the Data.

These methods return the optimal height for a row based on the data it contains. It loops through each cell in the row and calls the GetPreferredSize method on the IRenderer interface for the composite StyleInfo.Renderer for the cell in the style model and returns the maximum value.

If you have set up the cells to format the text with multiple lines (GeneralCellType with WordWrap equal to true, or TextCellType with Multiline or WordWrap or both equal to true), then the GetPreferredSize method returns the optimal height to show all of the text in the cell with the current row height. For text cells or header cells with text, be sure that you turn off word wrapping by setting the WordWrap property for that text cell or header cell to false.

If you have very many rows, then you might want to create a custom axis model for SheetView.DocumentModels.RowAxis to return this value. All that should require is creating a class derived from DefaultSheetAxisModel that takes a reference to the SheetView in its constructor and stores it in a field and overrides the GetSize method to call this method for the row index.

In other words, these methods loop through each cell and call GetPreferredSize on each cell's composite style's renderer and returns the maximum height for all cells in the row. Refer to GetPreferredSize to find the more detailed explanation of how that works with multiple-line versus single-line text.

For more information on how a composite style works, refer to ISheetStyleModel.GetCompositeInfo.

For rich text cells (RichTextCellType), if the WordWrap property is set to true, the row height returned by the GetPreferredRowHeight might be larger than what is necessary to display the entire cell if the last character on a wrapped line is on the border. Also, for rich text cells, if the Multiline property is set to true, the row height returned by the GetPreferredRowHeight might be smaller than what is necessary to display the entire cell if there are multiple font sizes and styles on each line.

See Also

Reference

SheetView Class
SheetView Members
GetPreferredHeight Method

User-Task Documentation

Resizing the Row or Column to Fit the Data