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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Checkbox Stops Working When GridBaseStyles are Changed

Thread ID:

Created:

Updated:

Platform:

Replies:

88878 Aug 13,2009 08:02 PM UTC Aug 27,2009 11:51 PM UTC Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 13, 2009 08:02 PM UTC

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

Administrator [Syncfusion]
Replied On 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?

Rajadurai C [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Rajadurai C [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;