Spread ASP.NET 6.0 Product Documentation
AutoGenerateColumns Property
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : AutoGenerateColumns Property


Glossary Item Box

Gets or sets whether to generate the columns automatically based on the data source.

Syntax

Visual Basic (Declaration) 
Public Property AutoGenerateColumns As Boolean
Visual Basic (Usage)Copy Code
Dim instance As DefaultSheetDataModel
Dim value As Boolean
 
instance.AutoGenerateColumns = value
 
value = instance.AutoGenerateColumns
C# 
public bool AutoGenerateColumns {get; set;}

Property Value

Boolean: true, for automatic generation, false otherwise

Example

This example creates a new DefaultSheetDataModel, binds it to a database and attaches it to the DataModel of the active sheet. It does not automatically generate its columns based on the columns in the database, but does so on an individual basis.
Visual BasicCopy Code
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load

If(IsPostBack)ThenReturn
DimconStrAsString="Provider=Microsoft.JET.OLEDB.4.0;datasource=d:\\nwind.mdb"
DimsqlStrAsString="SELECT*FROMEmployees"
DimconnAsSystem.Data.OleDb.OleDbConnection=NewSystem.Data.OleDb.OleDbConnection(conStr)
DimdsAsDataSet=NewDataSet()
DimdaAsSystem.Data.OleDb.OleDbDataAdapter=NewSystem.Data.OleDb.OleDbDataAdapter(sqlStr,conn)
da.Fill(ds,"Employees")
DimdmAsNewFarPoint.Web.Spread.Model.DefaultSheetDataModel()
dm.DataSource=ds
dm.AutoGenerateColumns=False
dm.SetModelDataColumn(0,2)
dm.SetModelDataColumn(1,1)
dm.DataKeyField="LastName"
FpSpread1.ActiveSheetView.DataModel=dm
conn.Close()
ListBox1.Items.Add(dm.ColumnCount)
ListBox1.Items.Add(dm.RowCount)
EndSub
C#Copy Code
privatevoidPage_Load(objectsender,System.EventArgse)
{
stringconStr="Provider=Microsoft.JET.OLEDB.4.0;datasource=d:\\nwind.mdb";
stringsqlStr="SELECT*FROMEmployees";
System.Data.OleDb.OleDbConnectionconn=newSystem.Data.OleDb.OleDbConnection(conStr);
DataSetds=newDataSet();
System.Data.OleDb.OleDbDataAdapterda=newSystem.Data.OleDb.OleDbDataAdapter(sqlStr,conn);
da.Fill(ds,"Employees");
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=newFarPoint.Web.Spread.Model.DefaultSheetDataModel(ds,"Employees");
dm.DataSource=ds;
dm.AutoGenerateColumns=false;
dm.SetModelDataColumn(0,2);
dm.SetModelDataColumn(1,1);
dm.DataKeyField="LastName";
FpSpread1.ActiveSheetView.DataModel=dm;
conn.Close();
ListBox1.Items.Add(Convert.ToString(dm.ColumnCount));
ListBox1.Items.Add(Convert.ToString(dm.RowCount));
}

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.