views:

27

answers:

1

I need to be able to turn off some cells in a row based on a boolean flag. If the flag is true I everything should be enabled and visible like normal. If the flag is false however I need to have several cells in the row made invisible and readonly.

+1  A: 

You can handle the CellPainting event, check the status of your flag there and then paint the cell to be shown/hidden.

This link on MSDN may help you in this:

http://msdn.microsoft.com/en-us/library/hta8z9sz.aspx

Mamta Dalal
Thanks. At the moment I'm using the DataBindingComplete event and setting the hidden cells to read only and changing all the colors to SystemColors.Window. Overriding the Paint event would also let me kill the cell borders, but since I've got a few different cell types I can't just use the sample code as a complete solution. For the moment I think I'll just note this as an option if I get pushback on the borders lingering.
Dan Neely