Column header refers to the fixed row/s on the top of the grid which contains a caption string, sort glyph etc. In True DBGrid control, by default, the top row with zero index is allocated for the column header. The Column Footer, on the other hand, refers to the last row of the grid which displays additional information about the whole column. The common use of a column footer is to show the summary of column data.
Let's see how to perform basic operations on the column header and footer.True DBGrid, when in bound mode, reads the field names from the data source and renders them as column header text. However, you can explicitly set Caption property of C1DataColumn class to set the text in the column header.
Specify the header rows and set the header text in WinForms True DBGrid using the code below.
C# |
Copy Code
|
---|---|
// Change the caption of a column c1TruedbGrid1.Columns["Model"].Caption = "Made By"; |
To style the column header, you can access the HeadingStyle property of C1TrueDBGrid class, and change the backcolor, border color, forecolor etc.
Style the column header of the WinForms True DBGrid using the code below.
C# |
Copy Code
|
---|---|
// Style headers c1TruedbGrid1.HeadingStyle.BackColor = Color.Beige; c1TruedbGrid1.HeadingStyle.Borders.Color = Color.Red; // Set height of the column caption c1TruedbGrid1.Splits[0].ColumnCaptionHeight = 50; |
You can also set wrapping of the header text using the following code:
C# |
Copy Code
|
---|---|
// Set wrapping
c1TruedbGrid1.HeadingStyle.Wrap = C1.Win.TrueDBGrid.TextWrapping.Wrap;
|
In True DBGrid, you can create the column footer by setting the ColumnFooters property of C1TrueDBGrid class to True, and using the FooterText property of C1DataColumn class.
The following code shows how to add a column footer in the WinForms True DBGrid.
C# |
Copy Code
|
---|---|
// Set footer // Make footer visible c1TruedbGrid1.ColumnFooters = true; // Set footer text c1TruedbGrid1.Columns[0].FooterText = "Footer 0"; c1TruedbGrid1.Columns[1].FooterText = "Footer 1"; |