We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Default headers in data bound grid

Hello, I''m using a data bound grid to display a DataTable. Is it possible (in Beta 2) to display automatically the default row and column headers (ie "A", "B", "C",... for the columns, "1", "2", "3", ... for the rows) in addition to the headers added by the DataBound Grid?

3 Replies

AD Administrator Syncfusion Team March 9, 2004 11:55 AM UTC

Do you want a second row of column header (and second column of row headers), or do you want to combine the desired text into a single header (maybe A-MyColumn 1, B-MyColumn2 etc). If you want two header rows, then you can set this.grid.Model.Rows.HeaderCount = 1; this.grid,Model.Rows.FrozenCount = 1; Then in aPrepareViewStyleInfo event handler, based on the value of e.ColIndex, you could explicitly set the e.Style.Text when e.RowIndex was 0 or 1. To convert e.ColIndex to a letter of the alphabet, you can call the static (Shared in VB) member GridRangeInfo.GetAlphaLabel method. Here is a little sample to give you the flavor of the kinds of things you can do. forum11507_4520.zip


SJ Samuel Jack March 10, 2004 01:58 PM UTC

Thanks for that, it seems to work fine. What about for the Row Headers? I want to have numbers 1, 2,3, ... down the side of the grid.


AD Administrator Syncfusion Team March 10, 2004 02:34 PM UTC

If you are handling PrepareViewStyleInfo as in the prevoius sample, you can add this else clause to the if to get teh numbers down the side. else if(e.ColIndex == 0 && e.RowIndex > 0) { e.Style.CellType = "Header"; e.Style.Text = e.RowIndex.ToString(); e.Style.Font.Bold = false; }

Loader.
Live Chat Icon For mobile
Up arrow icon