资 源 简 介
C# 为DataGridView控件的新行指定默认值,双击DataGridView.rar即可看到默认值,一般情况下,单元格是空的没有任何内容,实现这一功能,其实也简单,如下代码示:
private void shippersDataGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{//为DataGridView控件的新行指定默认值(测试时直接单击最下面的空白行即可)
e.Row.Cells[1].Value = "重庆长安捷达运输公司";
e.Row.Cells[2].Value = "023-40405690";
shippersBindingSource.AddNew();
}