Question

I looked at http://msdn.microsoft.com/en-us/library/7tas5c80.aspx for reference and it makes sense as far as editable column goes.

The question is how do I host a "view only" custom control in a DataGridView (WinForm and C#)?

Was it helpful?

Solution

Derive from DataGridViewCell and override the Paint methods.

OTHER TIPS

Another easy way would be to make that column one of the "DataKeyNames" columns of the grid. Any field that is considered a "Key" is by default disabled from a user editing it. However, if you deal with object analysis on "clicked" on records for editing, or other, the array of returned keys will be in the same sequence as they are listed in the DataKeyNames property. So, even though you may be ignoring the actual value as a "Key", it can act to disable it.

HTH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top