How do I allow edit only a particular column in datagridview in windows application?

后端 未结 3 753
攒了一身酷
攒了一身酷 2020-12-09 01:38

I want to enable only two columns in the DataGridview to be able to edit. The others should not be allowed to edit. Further I am not directly linking to datasource; I will b

3条回答
  •  醉酒成梦
    2020-12-09 02:30

    foreach (DataGridViewColumn dc in dataGridViewX1.Columns)
    {
           if (dc.Index.Equals(0) || dc.Index.Equals(1))
           {
               dc.ReadOnly = false;
           }
           else
           {
                dc.ReadOnly = true;
           }
     }
    

提交回复
热议问题