How to: Make Columns Read-Only in the Windows Forms DataGridView Control

Not all data is meant for editing. In the DataGridView control, the column ReadOnly property value determines whether users can edit cells in that column. For information about how to make the control entirely read-only, see How to: Prevent Row Addition and Deletion in the Windows Forms DataGridView Control.

There is support for this task in Visual Studio. Also see How to: Make Columns Read-Only in the Windows Forms DataGridView Control Using the Designer.

To make a column read-only programmatically

  • Set the DataGridViewColumn.ReadOnly property to true.

    dataGridView1.Columns["CompanyName"].ReadOnly = true;
    
    dataGridView1.Columns("CompanyName").ReadOnly = True
    

Compiling the Code

This example requires:

See also