Grid Checkbox Stops Working When GridBaseStyles are Changed

I'm using the GridDataBoundGrid with checkbox columns. I've found that when I change any GridBaseStyle in BaseStylesMap, the checkbox columns stop working. Why does this happen, and what can I do to make it work?

This is an example of how I initialize a checkbox column:

'Initialize ShowProgressChartColumn.
ShowProgressChartColumn = New GridBoundColumn
With ShowProgressChartColumn
.HeaderText = "Show Progress Chart"
.MappingName = "ShowProgressChart"
.StyleInfo.CellType = GridCellTypeName.CheckBox
.StyleInfo.CellValueType = GetType(System.Boolean)
.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Center
End With

This is how I change the GridBaseStyles:

Public Sub New()

'Loop through all base styles (Header, Row Header, Column Header, and Standard).
For Each GridBaseStyle As GridBaseStyle In BaseStylesMap

'Apply the standard font to this style.
With GridBaseStyle.StyleInfo.Font
.Facename = Globals.Facename
.Size = Globals.FontSize
End With

Next

End Sub

Can anyone spot what I'm doing wrong? All advice is appreciated.

-TC

5 Replies

AD Administrator Syncfusion Team August 16, 2009 05:32 PM UTC

Okay, I still haven't found a solution to this -- it has turned into one of those frustrating little bugs that consumes hours. I've been experimenting with various properties of the grid, and I can't find an approach that works.

No one has answered my original post yet, so I'm going to rephrase the question in a way that might be more likely to get a reply: Can anyone provide me with an example that changes the font for a grid, yet preserves the functionality of checkbox columns?


RC Rajadurai C Syncfusion Team August 17, 2009 01:52 PM UTC

Hi TC,

Thanks for your interest in Syncfusion Products.

I have tried to reproduce the issue with checkbox in a sample with the code settings provided. But it works fine. On analysing the issue reported, it seems the name of the column binded to grid to which the checkbox column has been mapped is not given properly in your application. Only then, you cannot make any changes in the checkbox. Please refer to the following sample in which the grid is binded with datatable. A gridboundcolumn with checkbox celltype is added and binded to the first column of binded datasource.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F88878.zip

If you still sees the issue, please try to reproduce it in the attached sample and provide us. It would be fine to see the issue and work to provide a better solution.

Regards,
Rajadurai


AD Administrator Syncfusion Team August 18, 2009 05:38 PM UTC

Rajadurai,

Thank you for the help. I appreciate the effort you spent to prepare sample code for me.

I've experimented further, and I've observed that the bug occurs whenever a GridBaseStyle is changed before the GridDataBoundGrid is added to a Controls collection. Please see the attached code for an example.

I was able to work-around the problem by setting the GridBaseStyles not in the New procedure, but in an Initialize override. Everything works fine now.

-TC



F88878_478eba41.zip


RC Rajadurai C Syncfusion Team August 19, 2009 11:14 AM UTC

Hi TC,

Thanks for your details.

In the provided sample, please try to call a method InitializeLifetimeService() of GridBoundColumns in constructor of CustomGrid class before setting base styles. This method initializes an object that refers to the instance of GridBoundColumns from here until its lifetime.

Me.GridBoundColumns.InitializeLifetimeService()

Here is the modified sample for your reference in which this has been implemented solving the issue with checkbox celltype column.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F88878a.zip

Regards,
Rajadurai


AD Administrator Syncfusion Team August 27, 2009 11:51 PM UTC

Rajadurai,

Thanks for your help. I've changed my code to use InitializeLifetimeService, and it is working great.

-TC

Loader.
Up arrow icon