You can set the row height or column width as a specified number of pixels. Each sheet uses and lets you set a default size, making all rows or columns in the sheet the same size. You can override that setting by setting the value for individual rows or columns.
You can set the column width with the Width property of the FpSpread component Columns object. You can set the row height with the Height property of the FpSpread component Rows object.
You can also use the DefaultColumnWidth property for the sheet to set the width for all columns in the sheet; use the SetColumnWidth method or use the Column Width property to set the width for a specific column. For row heights, set the DefaultRowHeight property for the sheet to set the height for all the rows in the sheet; use the SetRowHeight method or use the Row Height property to set the height for a specific row.
Users can change the row height or column width by dragging the header lines between rows or columns.
Using the Properties Window
- To change the default column width setting or row height, at design time, in the Properties window, select the Sheets property for the FpSpread component.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet for which to set the default column width or row height.
- Select the DefaultColumnWidth property in the property list or the DefaultRowHeight, and specify the width or height in pixels.
- Click OK to close the editor.
- To change the width or height for a specific column or row, select the Columns or Rows collection after selecting the sheet. Then select a column or row and set the width or height properties.
- Click OK to close the editor.
Using Code
Typically, set the default column width for the sheet and set the width of individual columns on that sheet as needed. Similarly, set the default row height for the sheet and set the height of individual rows on that sheet as needed.
Example
This example code changes the default width of all columns for the first sheet to 50 pixels, but makes the width of the second column 100 pixels.
C# | Copy Code |
---|---|
// Set default width to 50, but second column 100.
FpSpread1.Sheets[0].DefaultColumnWidth = 50;
FpSpread1.Sheets[0].Columns[1].Width = 100;
|
VB | Copy Code |
---|---|
' Set default width to 50, but second column 100.
FpSpread1.Sheets(0).DefaultColumnWidth = 50
FpSpread1.Sheets(0).Columns(1).Width = 100
|
Using Code
Set the Width property for a Column object.
Example
This example code sets the width of the second column to 100 pixels.
C# | Copy Code |
---|---|
FarPoint.Web.Spread.Column Col1; Col1 = fpSpread1.Sheets[0].Columns[1]; Col1.Width = 100; |
VB | Copy Code |
---|---|
Dim Col1 As FarPoint.Web.Spread.Column Col1 = FpSpread1.Sheets(0).Columns(1) Col1.Width = 100 |
Using the Spread Designer
- To set the default column width or row height,
- Select the sheet for which you want to set the default column width or row height.
- Select DefaultColumnWidth or DefaultRowHeight and set the width or height properties.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
- To set a specific column width or row height,
- Select the column or row for which you want to change the width or height.
- In the properties list for that column or row, change the Width property or the Height property.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.