Friday, July 04, 2008  



 FarPoint Technologies
 (800) 645-5913

 fpsales@fpoint.com



     
 »Spread for Windows Forms » Product Tour » Appearance » Rows and Columns

Previous Customizing the Appearance of Rows or Columns Next

  Back to Top
 Customizing the Number of Rows or Columns
When you create a sheet, it is automatically created with five hundred columns and five hundred rows. You can change the number from zero up to two billion column and rows.

// Sets the first sheet to have 2 columns and 100 rows.
fpSpread1.Sheets[0].ColumnCount = 2;
fpSpread1.Sheets[0].RowCount = 100;

' Sets the first sheet to have 2 columns and 100 rows.
FpSpread1.Sheets(0).ColumnCount = 2
FpSpread1.Sheets(0).RowCount = 100


  Back to Top
 Adding a Row or Column
You can add one or more columns or rows to a sheet, and specify where the column or row is added. You can use the methods in the SheetView class or the methods in the DefaultSheetDataModel class.

// Adds one column before column 3
fpSpread1.Sheets[0].AddColumns(3,1);

' Adds one column before column 3
FpSpread1.Sheets(0).AddColumns(3,1)


  Back to Top
 Removing a Row or Column
You can remove one or more columns or rows from a sheet. You can use the methods in the SheetView class or the methods in the DefaultSheetDataModel class.

// Removes a two columns before column 6
fpSpread1.Sheets[0].RemoveColumns(6,2);

' Removes two columns before column 6
FpSpread1.Sheets(0).RemoveColumns(6,2)


  Back to Top
 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. Users can change the row height or column width by dragging the header lines between rows or columns.

// Set column width to 100
fpSpread1.Sheets[0].Columns[0].Width = 100;

' Set column width to 100
FpSpread1.Sheets(0).Columns(0).Width = 100


  Back to Top
 Resizing the Row or Column to Fit the Data
You can resize the column width or row height based on the length or breadth of data in the cells in that column or row. The size of the row or column with the largest data is called the preferred size.

' Get the preferred width of the first column
Dim prefWidth As Single
prefWidth = fpSpread1.Sheets(0).Columns(0).GetPreferredWidth()
fpSpread1.ActiveSheet.Columns(0).Width = prefWidth


  Back to Top
 Hiding a Row or Column
You can hide rows or columns in a sheet. You can also hide row headers and column headers. You hide a row or column by setting the Row Visible property or Column Visible property to false.

// Hide row three
fpSpread1.Sheets(0).SetRowVisible(2, False)
// or
fpSpread1.Sheets[0].Rows[2].Visible = False;

' Hide row three
fpSpread1.Sheets(0).SetRowVisible(2, False)
' or
fpSpread1.Sheets(0).Rows(2).Visible = False


  Back to Top
 Creating Alternating Rows
You might want to set up your sheet so that alternating rows have a different appearance. For example, in a ledger, alternating rows often have a green background. In Spread, you can set up multiple alternating row appearances, which are applied in sequence, starting with the first row. Set up the alternating rows using an index into the alternating row appearances. It might help to think of the default row appearance as the first alternating row style (or style zero, because the index is zero-based). Set the other alternating row appearances to subsequent indices.

This example code creates a sheet that has three different appearance settings for rows. The first row uses the default appearance. The second row has a light blue background with navy text, and the third row has a light yellow background with navy text. This pattern repeats for all subsequent rows.

fpSpread1.Sheets[0].AlternatingRows.Count = 3;
fpSpread1.Sheets[0].AlternatingRows[1].BackColor = Color.LightBlue;
fpSpread1.Sheets[0].AlternatingRows[1].ForeColor = Color.Navy;
fpSpread1.Sheets[0].AlternatingRows[2].BackColor = Color.LightYellow;
fpSpread1.Sheets[0].AlternatingRows[2].ForeColor = Color.Navy;

FpSpread1.Sheets(0).AlternatingRows.Count = 3
FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightBlue
FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.Navy
FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.LightYellow
FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.Navy



Previous Customizing the Appearance of Rows or Columns Next


    
 Have a question?
Have a Question? Ask Us!
Subscribe to the RSS feed!RSS Subscribe
 

 
SD Times 'TOP 100' Industry Innovator - Read the press release (pdf)

Tour Home
Overview
Appearance
User Interaction
Cell Types
Formulas
Managing Data
Data Binding
Import/Export
Printing
Keyboard Interaction
Shapes
Models
Spread Designer
 
Map

Copyright © 1991-2007 FarPoint Technologies, Inc. All rights reserved. All names are property of their respective owners.