Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Managing Data Binding > Customizing Data Binding > Customizing Column Headers for Bound Sheets |
By default, sheets display the field names in the column headers when bound to a data set. If you prefer, you can change the text to display custom column names.
This example code binds the Spread component to a data set then customizes the first column header.
C# |
Copy Code
|
---|---|
// Bind the component to the data set. fpSpread1.DataSource = dbDataSet; // Set custom text in the first column header. fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "Student ID"; |
VB |
Copy Code
|
---|---|
' Bind the component to the data set. FpSpread1.DataSource = dbDataSet ' Set custom text in the first column header. FpSpread1.Sheets(0).ColumnHeader.Cells(0, 0).Text = "Student ID" |
This example code creates a bound SheetView object and customizes the text in the first column header cell, then assigns it to a sheet in a Spread component.
C# |
Copy Code
|
---|---|
// Create a new SheetView object. FarPoint.Win.Spread.SheetView newsheet = new FarPoint.Win.Spread.SheetView(); // Bind the SheetView object to the data set. newsheet.DataSource = dataSet1; // Change the column header text in the first header cell. newsheet.ColumnHeader.Cells[0, 0].Text = "Student ID"; // Assign the SheetView object to the first sheet. fpSpread1.Sheets[0] = newsheet; |
VB |
Copy Code
|
---|---|
' Create a new SheetView object. Dim newsheet As New FarPoint.Win.Spread.SheetView() ' Bind the SheetView object to the data set. newsheet.DataSource = DataSet1 ' Change the column header text in the first header cell. newsheet.ColumnHeader.Cells(0, 0).Text = "Student ID" ' Assign the SheetView object to the first sheet. FpSpread1.Sheets(0) = newsheet |