c# datagridview 相关操作。
string[] newRow = {"long","d","b"}; Gridview.Rows.Insert(Gridview.Rows.Count, newRow);
datagridview 设置某行某列的单元格可修改:
private void SetGridCellEdit() { if (repgrid != null && repgrid.Rows.Count > 0) { string dyeno = string.Empty; for (int i = 0; i < repgrid.Rows.Count; i++) { if (repgrid.Rows[i].Cells["Coldyeno"].Value != null) { dyeno = repgrid.Rows[i].Cells["Coldyeno"].Value.ToString(); if (dyeno.Equals("X022") || dyeno.Equals("X009") || dyeno.Equals("X008") || dyeno.Equals("X001") ) // { DataGridViewCell viewCell = repgrid.Rows[i].Cells["Coltarget"]; repgrid.CurrentCell = viewCell; viewCell.ReadOnly = false; repgrid.BeginEdit(true); } else { DataGridViewCell viewCell = repgrid.Rows[i].Cells["Coltarget"]; repgrid.CurrentCell = viewCell; viewCell.ReadOnly = true; } } } } }