Spread WPF Documentation
GetDataColumnName Method
Example 


GrapeCity.Windows.SpreadSheet.Data Namespace > Worksheet Class : GetDataColumnName Method
The column index for which the name is requested.
Gets the column name at the specified position.
Syntax
'Declaration
 
Public Function GetDataColumnName( _
   ByVal column As System.Integer _
) As System.String
'Usage
 
Dim instance As Worksheet
Dim column As System.Integer
Dim value As System.String
 
value = instance.GetDataColumnName(column)
public System.string GetDataColumnName( 
   System.int column
)

Parameters

column
The column index for which the name is requested.

Return Value

Returns the column name for data binding.
Exceptions
ExceptionDescription
Specified index is out of range; must be between 0 and the total number of columns.
Example
This example uses the GetDataColumnName method.
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

Worksheet Class
Worksheet Members