C# dataGridView用法,C#中dataGridView的快速学习
// DefaultValuesNeeded 事件处理方法
private void DataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
// 设定单元格的默认值
e.Row.Cells["Column1"].Value = 0;
e.Row.Cells["Column2"].Value = "-";
SqlDataAdapter da=new SqlDataAdapter(sql命令串,连接字符串); DataTable dtbl=new DataTable();
da.Fill(dtbl);
dataGridView1.DataSource=dtbl;