Hi,
I have a datagrid, after databinding with datatable, I can view my data from the table (it contains checkbox column).I want to be able to work directly with the checkbox column (meaning I will click directly on the checkbox without selecting the row), I have used this event to determine if the checkbox is checked:
private void sfDataGrid1_CellCheckBoxClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellCheckBoxClickEventArgs e) { var dataRowView = e.Record as DataRowView; if (e.Column.HeaderText == "Priority" && e.OldValue != CheckState.Checked) { dataRowView.Row[1] = true; } else { dataRowView.Row[1] = false; } }
This is not working.
Thanks,
Shaun
Hi The GridLock,
Thank you for sharing the code snippet with us.
We have reviewed your code snippet and your requirement. Your goal is to determine the status of the checkbox (checked or unchecked) when directly interacting with it.
In the CellCheckBoxClick event, the event argument includes a NewValue property, which reflects the new state of the checkbox after the click. However, in the provided code snippet, you are checking the old value instead. To achieve your requirement, you can use the NewValue property to retrieve the current state of the checkbox.
Code snippet:
private void SfDataGrid1_CellCheckBoxClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellCheckBoxClickEventArgs e) { var dataRowView = e.Record as DataRowView; if (e.Column.HeaderText == "Is Delivered" && e.NewValue == CheckState.Checked) { dataRowView.Row[1] = true; } else { dataRowView.Row[1] = false; } } |
Output:
If we have misunderstood your requirement, we kindly request you to share additional details, such as a video reference, to help us better understand your needs and provide an accurate solution.
We appreciate your cooperation and look forward to assisting you further.
Regards,
Sreemon Premkumar M.