日期:2014-05-18 浏览次数:21226 次
this.dataGridView1.ReadOnly = false; for (int i = 1; i <= this.dataGridView1.DisplayedColumnCount(false); i++) { if (i == 1) { this.dataGridView1.Columns[i].ReadOnly = false; } else { this.dataGridView1.Columns[i].ReadOnly = true; } }
this.dataGridView1.Columns[0].ReadOnly = false; this.dataGridView1.Columns[1].ReadOnly = true; this.dataGridView1.Columns[2].ReadOnly = true; this.dataGridView1.Columns[3].ReadOnly = true;
------解决方案--------------------
this.dataGridView1.ReadOnly = false; for (int i = [color=#FF0000]0[/color]; i [color=#FF0000]<[/color] this.dataGridView1.DisplayedColumnCount(false); i++) { if (i == 1) { this.dataGridView1.Columns[i].ReadOnly = false; } else { this.dataGridView1.Columns[i].ReadOnly = true; } }
------解决方案--------------------
private void dataGridView1(object sender, EventArgs e)
{
...
}
第一列是0
------解决方案--------------------
for (int i = 0; i < this.dataGridView1.Columns.Count; i++) { if(i==0) this.dataGridView1.Columns[i].ReadOnly = false; else this.dataGridView1.Columns[i].ReadOnly = true; }
------解决方案--------------------