We have a DataGridViewCheckBox column bound to a boolean property in our class.
The property setter has some logic which says that under certain conditions a True flag cannot be changed, ie, it stays checked forever. This is on a per record basis. So the entire column can't be readonly, only certain rows.
Pseudo code:
Public Property Foo() As Boolean
Get
Return _Foo
End Get
Set(ByVal value As Boolean)
If _Foo And Bar And value = False Then
//do nothing, in this scenario once you're true, you stay true
Else
_Foo = value
End If
End Set
End Property
Databinding is handling all of this fine, except that the checkbox is visibly cleared when it's clicked. Then, of course, when the binding / setter is fired (as you move off that cell) it is restored to its checked status per the underlying logic. Ultimately it doesn't matter too much but it's a clumsy UI.
How can we intercept the user's click and keep it checked?