I have a DataGridView with read-only mode set to true (non-editable) which takes values from a database on form load. When I set the read-only mode to false (editable mode), I want a particular column (eg. Department) to visible as ComboBox so i can select values from there. And when i enter the Read-Only mode, the ComboBox should disappear and DataGridView should be visible as normal. How to achieve it?
I am using C# framework 4.0, Winforms
I have a DataGridView with read-only mode set to true (non-editable) which takes values
Share
See the implementation at ComboBox with read only behavior.
You could also change the
DisplayStylebased on when the readonly of theDataGridViewproperty is changed. Setting theDisplayStyletoDataGridViewComboBoxDisplayStyle.Nothingwill hide the drop down button.For example, changing the
ReadOnlyproperty with a button click would look something like this:Editable:
ReadOnly: