I'm using the new column header checkbox in 9.1 and the BeforeHeaderCheckStateChanged event to check and uncheck all my custom object rows with UltraCheckEditor editor controls... but... I can't find any public property in the ColumnHeader class to get/set the value in code? I'd like to toggle it checked or unchecked based on loading my grid's cell object values, which are not boolean, but objects. Thanks.
Hello,
The method to set the CheckState of the header checkbox is exposed off of the column itself as SetHeaderCheckedState(). This method accepts a boolean to indicate if you want the checkbox to be checked or not.
SetHeaderCheckedState Method
If you would still like to utilize the synchronization functionality provided as part of the feature, you can create a DataFilter to convert your underlying objects to booleans. You can use this Knowledge Base article as a guide.
If you require further assisntance, feel free to let me know.
Thanks,
Chris
I can only seem to get this to fire if the CheckBoxSynchronization is set to Bands and then it appears that e.NewCheckedState == Intermediate. If CheckBoxSynchronization is set to None, SetHeaderCheckedState appears to have no effect?
What are you passing in to the SetHeaderCheckedState() method for the RowsCollection?
Here is a little of what happens behind the scenes. Due to the re-creation of UIElements, we cache the current CheckState for the header on either the UltraGridBand or RowsCollection object. If the synchronization resolves to Band, it is cached on the Band, and all HeaderUIElements for that Band access this cached value to display the checkbox in the appropriate checked state. For the other resolved synchronizaitons (Row and None), the CheckState is cached on the RowsCollection. The HeaderUIElement uses it's Context to determine which RowsCollection it is associated with, and uses it to retrieve/assign the CheckState.
Passing a null for the Rows parameter will only set the CheckState if the synchronization resolves to Band, as column cannot determine which set of Rows to apply the CheckState to.
By passing the <grid>.Rows or <grid>.DisplayLayout.Rows as the Rows parameter, it should be setting the CheckState for the column (should it exist) in the root-level RowsCollection. If the column is part of a Band other than the root Band (Band[0]), the operation will have no affect.
How you access the appropriate RowsCollection will depend on when you attempting to perform your synchronization. For instance, if you are looking to set the CheckState on the Header CheckBox during the CellChange event hander, you would have to use the cell's Row.ParentCollection property.
I tried using both null or the grid's Rows. Nothing seemed to trigger the checkbox unless Synchronization was set to Band. I really want Synchronization to truly be none as I'd like to have control and the ability to override. (I've also seen a related post and feature request to overload SetHeaderCheckedState to accept a CheckState enum instead of just bool to allow setting header checkbox to intermediate state.)