What I want is pretty simple: I have a column of checkboxes in a DataViewGrid. It's possible for the user to check something that should be refused and I'm having no luck doing so. Here's my current version of the CurrentCellDirtyStateChanged routine:
if (!FileGrid.IsCurrentCellDirty) return;
FileGrid.CommitEdit(DataGridViewDataErrorContexts.Commit);
int Row = FileGrid.CurrentCell.RowIndex;
OneFile Item = (OneFile) FileGrid[0, Row].Tag;
GroupInfo ThisGroup = Item.Group;
if (Item.Selected)
Item.Selected = false;
else if (ThisGroup.Selected < ThisGroup.Files.Count - 1)
Item.Selected = true;
else
{
DataGridViewCheckBoxCell Cell = (DataGridViewCheckBoxCell)FileGrid[0, Row];
Cell.Selected = false;
Console.Beep();
}
In terms of actual functionality this works correctly--Item.Selected is always set like it's supposed to be. However, when the check is rejected the screen still shows a check on the cell. I've tried Cell.Value = false and some strange ideas that I found on the web that did no better.
(The logic here is that the items are divided into groups and it's not permissible to select every member of a group.)
Aucun commentaire:
Enregistrer un commentaire