Spread Windows Forms 7.0 Product Documentation
GetPreferredRowHeight Method
See Also  Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class : GetPreferredRowHeight Method


Glossary Item Box

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
GetPreferredRowHeight(Int32)Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
GetPreferredRowHeight(Int32,Boolean)Gets the height in pixels of the tallest cell (based on text content) in the specified row on this sheet.  
GetPreferredRowHeight(Int32,Boolean,Boolean)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.

Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8

See Also

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.