1.if (dataGridView1.Rows.Count < 1) return;
int index = dataGridView1.CurrentRow.Index; //获取当前选中行索引号
dataGridView1.Rows[index].Selected = true; //加亮显示
string Inven_No = this.dataGridView1["InventoryNo", index].Value.ToString();
2.if (ds.Tables["tb"].Rows.Count == 0)
{ MessageBox.Show("没有符合条件的数据"); }
3.
OracleDataAdapter da = new OracleDataAdapter(strSQL, conn);
ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("没有符合条件的数据");
}
da.Dispose();
this.bindingSource1.DataSource = ds.Tables[0];
this.bindingNavigator1.BindingSource = bindingSource1;
this.dataGridView1.DataSource = bindingSource1;
this.dataGridView1.DefaultCellStyle.SelectionBackColor = Color.LightSteelBlue;
this.dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Black;
datagridview无数据显示问题处理
最新推荐文章于 2024-04-12 18:29:48 发布