Spread Windows Forms 6.0 Product Documentation
Width Property
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > Column Class : Width Property


Glossary Item Box

Gets or sets the width of cells in this column.

Syntax

Visual Basic (Declaration) 
Public Property Width As Single
Visual Basic (Usage)Copy Code
Dim instance As Column
Dim value As Single
 
instance.Width = value
 
value = instance.Width
C# 
public float Width {get; set;}

Property Value

Value of the width in pixels

Exceptions

ExceptionDescription
System.ArgumentOutOfRangeException Specified width is out of range; must be between -1 and 9,999,999 pixels

Remarks

This is equivalent to the SheetView.SetColumnWidth method. For more information on setting the size of the column, refer to Setting the Row Height or Column Width.

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

You can allow users to resize columns by setting the Resizable property. If the user is allowed to resize columns, when the user resizes a column, the FpSpread.ColumnWidthChanged and SheetView.ColumnChanged events occur.

Example

This example determines the width of the column based on the text in the first cell.
Visual BasicCopy Code
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
C#Copy Code
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;

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

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