Spread for ASP.NET 8.0 Product Documentation
Setting the Cell Types for Bound Data

The bound data may be any of several types and Spread provides different cell types to display that data effectively. Most often, you can use the DataAutoCellTypes property of the sheet to allow Spread to automatically match the best cell type with the cells of data. With this property you can turn off the automatic assignment if in certain cases you want to control the cell type. For example, if you have a column of 1's and 0's but you want to treat them as check box settings (checked and unchecked) instead of as numbers, then you can turn off automatic assignment and assign the check box cell type to that column of cells.

For more information about the cell types available, refer to Customizing with Cell Types.

Using the Properties Window

  1. At design time, in the Properties window, select the FpSpread component.
  2. Select the Sheets property.
  3. Click the button to display the SheetView Collection Editor.
  4. Set the DataAutoCellTypes property.
  5. Select OK.

Using a Shortcut

Set the DataAutoCellTypes property.

Example

This example code sets the DataAutoCellTypes property.

C#
Copy Code
FpSpread1.Sheets[0].DataAutoCellTypes = true;
VB
Copy Code
FpSpread1.Sheets(0).DataAutoCellTypes = True

Using Code

  1. Create a data source.
  2. Create a check box cell column.
  3. Set the DataAutoCellTypes property to false.
  4. Set the Spread DataSource property to the data source.

Example

This example code sets the DataAutoCellTypes property to false and uses a check box cell for the number data.

C#
Copy Code
DataSet ds = new System.Data.DataSet();
DataTable name;
DataTable city;
name = ds.Tables.Add("Customers");
name.Columns.AddRange(new DataColumn[] {new DataColumn("LastName", typeof(string)), new DataColumn("FirstName", typeof(string)), new DataColumn("ID", typeof(Int32))});
name.Rows.Add(new object[] { "Fielding", "William", 0 });
name.Rows.Add(new object[] { "Williams", "Arthur", 1 });
name.Rows.Add(new object[] { "Zuchini", "Theodore", 1 });
city = ds.Tables.Add("City/State");
city.Columns.AddRange(new DataColumn[] {new DataColumn("City", typeof(string)), new DataColumn("Owner", typeof(Int32)), new DataColumn("State", typeof(string))});
city.Rows.Add(new object[] { "Atlanta", 0, "Georgia" });
city.Rows.Add(new object[] { "Boston", 1, "Mass." });
city.Rows.Add(new object[] { "Tampa", 2, "Fla." });
FpSpread1.Sheets[0].Columns[2].CellType = new FarPoint.Web.Spread.CheckBoxCellType();
FpSpread1.Sheets[0].DataAutoCellTypes = false;
FpSpread1.DataSource = ds;
VB
Copy Code
Dim ds As New System.Data.DataSet
Dim name As System.Data.DataTable
Dim city As System.Data.DataTable
name = ds.Tables.Add("Customers")
name.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("LastName", Type.GetType("System.String")), New System.Data.DataColumn("FirstName", Type.GetType("System.String")), New System.Data.DataColumn("ID", Type.GetType("System.Int32"))})
name.Rows.Add(New Object() {"Fielding", "William", 0})
name.Rows.Add(New Object() {"Williams", "Arthur", 1})
name.Rows.Add(New Object() {"Zuchini", "Theodore", 1})
city = ds.Tables.Add("City/State")
city.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("City", Type.GetType("System.String")), New System.Data.DataColumn("Owner", Type.GetType("System.Int32")), New System.Data.DataColumn("State", Type.GetType("System.String"))})
city.Rows.Add(New Object() {"Atlanta", 0, "Georgia"})
city.Rows.Add(New Object() {"Boston", 1, "Mass."})
city.Rows.Add(New Object() {"Tampa", 2, "Fla."})
FpSpread1.Sheets(0).Columns(2).CellType = New FarPoint.Web.Spread.CheckBoxCellType()
FpSpread1.Sheets(0).DataAutoCellTypes = False
FpSpread1.DataSource = ds

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback