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

Header rows

I'm using a GridDataBoundGrid. I would like to have two header rows - row(0) to be a covered cell, i.e. the Caption for the grid, and row(1) to be the column headers. The following code does not work Me.GridDataBoundGrid1.Model.Rows.HeaderCount = 1 Me.GridDataBoundGrid1.Model.Rows.FreezeRange(0, 1) Me.GridDataBoundGrid1.Model.CoveredRanges.Add(New GridRangeInfo().Row(0)) For i As Integer = 0 To Me.GridDataBoundGrid1.GridBoundColumns.Count - 1 Me.GridDataBoundGrid1.Model.Item(1, i).Text = Me.GridDataBoundGrid1.GridBoundColumns(i).HeaderText Next While I get the two header rows as I want, as soon as the grid fills with data, row(1) disappears. How do I get the grid to fill from row(2) onwards? Thanks Jeremy

5 Replies

AD Administrator Syncfusion Team April 19, 2003 12:19 PM UTC

Here is code that works for me in version 1.5.2.0. The idea is to hide the top header row which is where the grid tries to put its headers. Then add 2 new header rows. The GridDataBoundGrid should start populating under the last header row.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.SqlDataAdapter1.Fill(Me.DataSet11)

        Me.GridDataBoundGrid1.Model.Data.RowCount = 2
        Me.GridDataBoundGrid1.Model.Rows.HeaderCount = 2
        Me.GridDataBoundGrid1.Model.Rows.FrozenCount = 2
        Me.GridDataBoundGrid1.Model.Rows.Hidden(0) = True
        Me.GridDataBoundGrid1.Model.CoveredRanges.Add(GridRangeInfo.Cells(1, 1, 1, Me.GridDataBoundGrid1.Model.ColCount))
        Dim i As Integer
        For i = 0 To Me.GridDataBoundGrid1.GridBoundColumns.Count - 1
            Me.GridDataBoundGrid1.Model.Item(2, i).Text = Me.GridDataBoundGrid1.GridBoundColumns(i).HeaderText
        Next

        Me.GridDataBoundGrid1.Model.Item(1, 1).Text = "Big Title"
    End Sub


UN Unknown Syncfusion Team April 19, 2003 12:52 PM UTC

Clay - it works, but you can not set the column widths at run time. I think I'll just embed the grid in a panel with a label on top Thanks Jeremy


AD Administrator Syncfusion Team April 19, 2003 01:08 PM UTC

You should be able to set colwidths at runtime. Make sure gridDataBoundGrid1.AllowResizeToFit is set to false. Then to change the with of column 4, use code like gridDataBoundGrid.Model.ColWidths(4) = 200


UN Unknown Syncfusion Team April 19, 2003 06:51 PM UTC

I meant to say that you can't drag the column with the mouse.


AD Administrator Syncfusion Team April 19, 2003 08:28 PM UTC

If you want to support dragging columns, then using a panel with a label as you suggested would be a simpler way to go.

Loader.
Up arrow icon