We have XtraGrid data formats in our Windows form. One of the columns is a check box. The problem is this: when users check the box and click the OK button, the box checked explicitly is not considered a checked grid. When I do this (while looping through the lines):
isAllowed = Convert.ToBoolean(viewMain.GetRowCellValue(nRowCtr, "IsAllowed"))
I will be back False. BUT, if the user checks the checkbox and then clicks somewhere else on the form or on another line in this grid, diverting focus from the checked checkbox, the same code will return True.
Any understanding of how to fix this behavior would be greatly appreciated.
Workaround: With the default settings, when users click on a cell to edit it, the cell goes into edit mode, loads an editor control (in this case, I have a CheckEdit repository control) and changes the control value (in this case, the checked state). If I click on another row or other control, the cell exits edit mode, fixing the change of the data element. But if I press the button, then my change will be lost. The workaround is to use the CheckEdit CheckedChanged event to close the editor:
Private Sub edCheck_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edCheck.CheckedChanged gridYears.FocusedView.CloseEditor() End Sub
Alex polkhovsky
source share