DataGridView一些总结
2021-03-09 22:30
标签:connect view span mes ini datatable open() ase man 如下: 数据集t填充: 未完待续... DataGridView一些总结 标签:connect view span mes ini datatable open() ase man 原文地址:https://www.cnblogs.com/tiancaige/p/12723957.htmlDataTable dt = (DataTable)this.dataGridView1.DataSource; //数据集转化为DataTable
dataGridView1.Rows.Count //数量统计
int ccc = dataGridView1.CurrentCell.RowIndex;//当前行下标
string smaterialNoFinish = dataGridView1[0, ccc].Value.ToString();// 第ccc行第一列的值
string[] str = new string[dataGridView1.Rows.Count];
string sql = " select .....";
try
{
SqlConnection Sqlconn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(sql, Sqlconn);
Sqlconn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sql, Sqlconn);
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
Sqlconn.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message, "查找失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}