Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to Disable a column in a Data Grid View in Winform

I have a data grid view ( say 5 columns ) . User has the option to disable/enable 1 particular column of the data table (using radio buttons). So How should I go about doing it?

When I select to disable the column, I need to make it non editable, change the color of the column so that user can understand that the column is disabled and any other suggestion are also welcome.

like image 982
Ananth Avatar asked Nov 13 '10 19:11

Ananth


People also ask

How do I hide a column in grid view?

To hide a column programmaticallySet the DataGridViewColumn. Visible property to false .

How do I make DataGrid read-only?

Set the IsReadOnly property to true to make all the cells in the DataGrid read-only. To make individual columns or cells read-only, set the DataGridColumn. IsReadOnly or DataGridCell. IsReadOnly properties.

How do I stop sorting in DataGrid?

Disabling Column Sorting | ComponentOne DataGrid for WPF and Silverlight. By default end users can sort columns in the grid at run time. For more information, see Sorting Columns. If you choose, however, you can disable the column sorting feature by setting the CanUserSort property to False.

What is difference between DataGridView and DataGrid control in Winforms?

The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together.


1 Answers

Set the column's ReadOnly property to true to make it non-editable. And alter its DefaultCellStyle.BackColor (and/or ForeColor) to make it obvious to the user.

like image 136
Hans Passant Avatar answered Nov 14 '22 21:11

Hans Passant