How to display the ReadOnly custom CheckBox while on PrintPreview in WinForms GridGroupingControl?
Show custom checkbox while on print preview
You can display the ReadOnly custom CheckBox by setting the CellType of a column style as CheckBox dynamically while printing the Grid by using the QueryCellStyleInfo event. In the following code example, the column, ParentDec, is changed to a CheckBox dynamically on PrintingMode.
void TableDescriptor_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(this.gridGroupingControl1.TableControl.PrintingMode)
{
if(e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "ParentDec"
&& e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
e.Style.CellType = GridCellTypeName.CheckBox;
e.Style.CellValue = ((int)e.Style.CellValue == 1);
}
}
}
Private Sub TableDescriptor_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
If Me.gridGroupingControl1.TableControl.PrintingMode Then
If e.TableCellIdentity.Column IsNot Nothing AndAlso e.TableCellIdentity.Column.Name = "ParentDec" AndAlso e.TableCellIdentity.DisplayElement.Kind Is DisplayElementKind.Record Then
e.Style.CellType = GridCellTypeName.CheckBox
e.Style.CellValue = (CInt(Fix(e.Style.CellValue)) = 1)
End If
End If
End Sub
The following screenshots display ParentDec before and after changing to a CheckBox:
Figure 1: ReadOnly ParentDec column before change
Figure 2: ReadOnly CheckBox column on print preview
Samples:
C#: Readonly-C#
VB: Readonly-VB
Conclusion
I hope you enjoyed learning how to display the ReadOnly custom CheckBox while on PrintPreview in WinForms GridGroupingControl.
You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!