Spread for ASP.NET 12 Product Documentation
Setting the Row Height or Column Width
Spread for ASP.NET 12 Product Documentation > Developer's Guide > Customizing the Appearance > Customizing the Appearance of Rows and Columns > Setting the Row Height or Column Width

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

  1. 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.
  2. Click the button to display the SheetView Collection Editor.
  3. In the Members list, select the sheet for which to set the default column width or row height.
  4. Select the DefaultColumnWidth property in the property list or the DefaultRowHeight, and specify the width or height in pixels.
  5. Click OK to close the editor.
  6. 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.
  7. 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

  1. To set the default column width or row height,
    1. Select the sheet for which you want to set the default column width or row height.
    2. Select DefaultColumnWidth or DefaultRowHeight and set the width or height properties.
    3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
  2. To set a specific column width or row height,
    1. Select the column or row for which you want to change the width or height.
    2. In the properties list for that column or row, change the Width property or the Height property.
    3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.