Spread Windows Forms 8.0 Product Documentation
GetPreferredWidth Method
Example 


Gets the minimum width necessary to display all the text within the specified column.
Syntax
'Declaration
 
Public Function GetPreferredWidth() As Single
'Usage
 
Dim instance As Column
Dim value As Single
 
value = instance.GetPreferredWidth()
public float GetPreferredWidth()

Return Value

Remarks

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.

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

Example
This example determines the width of the column based on the text in the first cell.
FarPoint.Win.Spread.Column col;
float size;
col = fpSpread1.ActiveSheet.Columns[0];
fpSpread1.ActiveSheet.Cells[0, 0].Text = "This text will be used to determine the width of the column";
size = col.GetPreferredWidth();
col.Width = size;
Dim col As FarPoint.Win.Spread.Column
Dim size As Single
col = FpSpread1.ActiveSheet.Columns(0)
FpSpread1.ActiveSheet.Cells(0, 0).Text = "This text will be used to determine the width of the column"
size = col.GetPreferredWidth()
col.Width = size
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

Reference

Column Class
Column Members
GetPreferredColumnWidth Method

User-Task Documentation

Resizing the Row or Column to Fit the Data

 

 


Copyright © GrapeCity, inc. All rights reserved.