There is probably a simple solution to this, so excuse me if I'm being a bit dumb...
I have a DataGridView bound to a collection. It displays a text column and a checkbox column. This binds to a string and bool property on my object. Simple stuff.
The problem is I have another boolean property that defines whether the checkbox should be displayed. What I need to do is display the check box if this property is set to true, and hide it if false, on a row by row basis.
Any ideas? Thanks.
DataGridView has so many events - there's probably a way to do this (might involve owner-drawn cells). I've used the CellFormatting event in the past to customize how field values are displayed. Either this event or the CellPaiting event might be of use. If you can't find the solution, you might check out the MSDN forums as well.
After all that, it now turns out I don't need to do what I said
I did come up with a couple of solutions, but neither were ideal. The first was to make the column read only, and use a context menu to modify the value. In that way I could check on the popup event whether the given row can have the boolean value edited.
The other way is similar by using the context menu (or a button etc). If I make the value a nullable bool and make the column a text column then I will either get "True", "False", or "". Still, a bit untidy though.
Maybe a solution would be to create a new DataGridView Column type...
Copyright (c) Marimer LLC