Posted 6 December 2019, 1:57 am EST
Hi Jagdeesh,
Thanks for providing the sample and screenshots.
1. Regarding hidden Checkboxes being shown when clicked on the cell:
Since we explicitly hide the cell content and cell clicks are handled by DataGrid (not knowing that cell element is hidden) to make a cell editable hence the behavior. To resolve this issue, you can handle the C1DataGrid.BeginningEdit event and cancel the edit if the cell meets some specified criteria.
private void C1DataGrid_BeginningEdit(object sender, C1.WPF.DataGrid.DataGridBeginningEditEventArgs e)
{
if(IsCellSatisfyingCondition(c1DataGrid[e.Row, e.Column]))
{
e.Cancel = true;
}
}
2. Regarding Scrolling issue:
C1DataGrid reuses the cell elements for better performance. So, we also need to set the checkboxes’ visibility back to visible if the cell does not meet the specified criteria.
private void C1DataGrid_LoadedCellPresenter(object sender, C1.WPF.DataGrid.DataGridCellEventArgs e)
{
if(e.Cell.Presenter.Content!=null && e.Cell.Presenter.Content is CheckBox)
{
var chb = e.Cell.Presenter.Content as CheckBox;
chb.Visibility = IsCellSatisfyingCondition(e.Cell) ? Visibility.Collapsed : Visibility.Visible;
}
}
Please verify the above with the attached modified sample.
Regards,
Basant
prj_HideCheckboxInCell_Mod.zip