I have a grid with read only columns and one checkbox column.
I set the grids CellClickAction: grid.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect
because I have a click event handler on the grid to process the selected row.
The issue is when I check the checkbox, the check never makes it through.
My workaround is as follows:
private void grid_MouseClick(object sender, MouseEventArgs e) { var ug = (UltraGrid)sender; if (ug.ActiveCell != null && ug.ActiveCell.Column.Key.Equals("Check")) { ug.ActiveRow.Selected = true; ((CheckEditor) ug.ActiveCell.EditorResolved).CheckState = CheckState.Checked; } var selectedRows = grid.Selected; if (selectedRows == null || selectedRows.Rows.Count == 0) return; Service.RowClicked(selectedRows.Rows[0] .ListObject as IViewModel);
But as soon as you "select" the ActiveRow it clears the check box again.
Hello,
If I understand correctly, the intent of your workaround is to toggle the checkbox even though this doesn't normally happen in Row Select mode. Please try the below approach, which handles CellClick instead of MouseClick:
private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e) { if (e.Cell.Column.DataType == typeof(bool)) e.Cell.Value = !(bool)e.Cell.Value; }
Please let me know if this works for you.
I should have clarified. I still need the mouse click event to be able to select the active row and process it. I tried the click cell event handler and the mouse click event logic clears out the check and doesnt seem to retain the selected active row.
Hi Kodie,
Using CellClick to handle the check box shouldn't interfere with row selection, row activation, or the MouseClick event. I've put together a quick sample to show you how you might implement it in your application. Please try it out and let me know if it works for you.
CheckboxRowSelect.zip