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
close icon

Problem with VirtTreeGrid sample

I''m trying to extend this sample so that I can programmatically set the column headers after loading the data. I''ve tried: Me.gridControl1(0, 3).Text = "12345" Me.gridControl1(1, 3).Text = "54321" but only cell(1,3) gets updated. Any ideas why the column headers aren''t being updated. Thanks Akash

5 Replies

AD Administrator Syncfusion Team September 13, 2005 03:08 PM UTC

Another problem: I can''t resize the column widths at runtime. Is there some grid property that must be set to allow this?


AD Administrator Syncfusion Team September 14, 2005 02:15 PM UTC

I put your code in a button handler and it worked OK for me on the click of the button. Both values were set. You should set to see if you have somehow set a ReadOnly style property on the header cell. That would prevent your code from working. The ResizeColsBehavior property is how control whether your user can resize the colwidths. Make sure you do not have this set to none.


AD Administrator Syncfusion Team September 14, 2005 02:19 PM UTC

I am sorry. I do see the problem in the VirtTree sample with the header not being set. I will update this when I have more informastion.


AD Administrator Syncfusion Team September 14, 2005 02:26 PM UTC

To set the headers, you can add code to QueryCellInfo an dset them there.
Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)

            If e.RowIndex = 0 And e.ColIndex > 0 Then
                e.Style.Text = String.Format("col{0}", e.ColIndex)
            ElseIf ((e.RowIndex > 0) _
                        AndAlso (e.ColIndex > 0)) Then
                e.Style.CellValue = externalData((e.RowIndex - 1)).Items((e.ColIndex - 1))
                If (e.ColIndex = 1) Then
                    e.Style.CellType = "TreeCell"
                    e.Style.Tag = externalData((e.RowIndex - 1)).IndentLevel
                    e.Style.ImageIndex = CType(externalData((e.RowIndex - 1)).ExpandState, Integer)
                End If
                e.Handled = True
            End If

        End Sub
The reason you cannot size the columns is that the columns widths are being set in the QueryColWidth event. You would have to remove that event to allow for teh default sizing to take place, or you would have to change the handler to size things in the event.


AD Administrator Syncfusion Team September 15, 2005 11:43 AM UTC

Thanks Clay, Both your fixes work as expected. Akash

Loader.
Live Chat Icon For mobile
Up arrow icon