Spread WPF Documentation
AutoGenerateColumns Property
Example 


Gets or sets whether to automatically generate the columns for a sheet based on the data source.
Syntax
'Declaration
 
<System.ComponentModel.DefaultValueAttribute()>
Public Property AutoGenerateColumns As System.Boolean
'Usage
 
Dim instance As Worksheet
Dim value As System.Boolean
 
instance.AutoGenerateColumns = value
 
value = instance.AutoGenerateColumns
[System.ComponentModel.DefaultValue()]
public System.bool AutoGenerateColumns {get; set;}

Property Value

Boolean: true to automatically generate columns; otherwise, false.
Example
This example sets the AutoGenerateColumns property.
System.Data.DataTable dt = new System.Data.DataTable("Test");
System.Data.DataRow dr = default(System.Data.DataRow);
dt.Columns.Add("Series0");
dt.Columns.Add("Series1");
dr = dt.NewRow();
dr[0] = 2;
dr[1] = 1;
dt.Rows.Add(dr);    
dr = dt.NewRow();
dr[0] = 4;
dr[1] = 2;
dt.Rows.Add(dr);    
dr = dt.NewRow();
dr[0] = 3;
dr[1] = 4;
gcSpreadSheet1.Sheets[0].AutoGenerateColumns = true;
gcSpreadSheet1.Sheets[0].DataSource = dt;
gcSpreadSheet1.Invalidate();

private void button1_Click(object sender, RoutedEventArgs e)
  {
        gcSpreadSheet1.Sheets[0].ReloadBindingData();
        gcSpreadSheet1.Invalidate();
  }
Dim dt As New System.Data.DataTable("Test")
Dim dr As System.Data.DataRow
dt.Columns.Add("Series0")
dt.Columns.Add("Series1")
dr = dt.NewRow()
dr(0) = 2
dr(1) = 1
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 4
dr(1) = 2
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = 3
dr(1) = 4
dt.Rows.Add(dr)
GcSpreadSheet1.Sheets(0).AutoGenerateColumns = True
GcSpreadSheet1.Sheets(0).DataSource = dt
GcSpreadSheet1.Invalidate()

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        GcSpreadSheet1.Sheets(0).ReloadBindingData()
        GcSpreadSheet1.Invalidate()
    End Sub
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional (SP4), Windows XP (SP2), Windows 2008, Windows 2003 Server (SP1)

See Also

Reference

Worksheet Class
Worksheet Members

 

 


Copyright © GrapeCity, inc. All rights reserved.