Spread WPF Documentation
DataField Property
Example 


GrapeCity.Windows.SpreadSheet.Data Namespace > Column Class : DataField Property
Gets or sets the data field for this column in the data source.
Syntax
'Declaration
 
<System.ComponentModel.DefaultValueAttribute()>
Public Property DataField As System.String
'Usage
 
Dim instance As Column
Dim value As System.String
 
instance.DataField = value
 
value = instance.DataField
[System.ComponentModel.DefaultValue()]
public System.string DataField {get; set;}

Property Value

The data field for this column in the data source. The default value is an empty string, which means that no data field is set for this column.
Example
This example sets the DataField 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

Reference

Column Class
Column Members