How To: Read Only DataGridView Control, C#

Quick Tip:
By Default, DataGridView control columns are set as editable, but in many cases, you may not want your grid data to be edited, or you may want to set your own controls that enable when and how the data get edited. The following C# code snippet will set the DataGridView columns of your DataGridView to ReadOnly.

foreach(DataGridViewColumn dc in My_DataGridView.Columns){
dc.ReadOnly = true;
}

This snippet iterates through the  DataGridView.Columns collection and sets  the ReadOnly property for each DataGridViewColumn item referenced as dc to true (boolean).