Spread WPF Documentation
GrapeCity.Windows.SpreadSheet.Data Namespace / Worksheet Class / DataAutoHeadings Property
Example


In This Topic
    DataAutoHeadings Property
    In This Topic
    Gets or sets whether to automatically generate column names for a sheet based on the data source.
    Syntax
    'Declaration
     
    <DefaultValueAttribute(True)>
    Public Property DataAutoHeadings As Boolean
    'Usage
     
    Dim instance As Worksheet
    Dim value As Boolean
     
    instance.DataAutoHeadings = value
     
    value = instance.DataAutoHeadings
    [DefaultValue(true)]
    public bool DataAutoHeadings {get; set;}

    Property Value

    Boolean: true to automatically generate column names; otherwise, false.
    Example
    This example sets the DataAutoHeadings 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].DataSource = dt;
    gcSpreadSheet1.Sheets[0].DataAutoHeadings = true;
    gcSpreadSheet1.Sheets[0].BindDataColumn(1, "Series0");
    gcSpreadSheet1.Sheets[0].Columns[0].DataField = "Series1";
    gcSpreadSheet1.Invalidate();
    
       private void button1_Click(object sender, RoutedEventArgs e)
           {
          Boolean r;
          Boolean c;
          string colinfo;
          object colinfo1;
          r = gcSpreadSheet1.Sheets[0].IsRowBound(0);
          c = gcSpreadSheet1.Sheets[0].IsColumnBound(0);
          colinfo = gcSpreadSheet1.Sheets[0].GetDataColumnName(1);
          colinfo1 = gcSpreadSheet1.Sheets[0].GetColumnDataType(1);
          listBox1.Items.Add(r.ToString());
          listBox1.Items.Add(r.ToString());
          listBox1.Items.Add(colinfo.ToString());
          listBox1.Items.Add(colinfo1.ToString());
          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).DataSource = dt
    GcSpreadSheet1.Sheets(0).DataAutoHeadings = True
    GcSpreadSheet1.Sheets(0).BindDataColumn(1, "Series0")
    GcSpreadSheet1.Sheets(0).Columns(0).DataField = "Series1"
    GcSpreadSheet1.Invalidate()
    
        Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
            Dim r As Boolean
            Dim c As Boolean
            Dim colinfo As String
            Dim colinfo1 As Object
            r = GcSpreadSheet1.Sheets(0).IsRowBound(0)
            c = GcSpreadSheet1.Sheets(0).IsColumnBound(0)
            colinfo = GcSpreadSheet1.Sheets(0).GetDataColumnName(1)
            colinfo1 = GcSpreadSheet1.Sheets(0).GetColumnDataType(1)
            ListBox1.Items.Add(r.ToString())
            ListBox1.Items.Add(r.ToString())
            ListBox1.Items.Add(colinfo.ToString())
            ListBox1.Items.Add(colinfo1.ToString())
            GcSpreadSheet1.Invalidate()
        End Sub
    See Also