如何判断DataGridView里显示的数据是哪个表的内容

来源:百度知道 编辑:UC知道 时间:2024/05/14 02:54:38
private void btnDel_Click(object sender, EventArgs e)
{
if (btnGoods.MouseClick)
{
datacon.getcom("delete from tb_Goods where GoodsNum<=0");
MessageBox.Show("删除用户信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (btnSell.Click)
{
datacon.getcom("delete from tb_Sell where GoodsNum<=0");
MessageBox.Show("删除用户信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
if (btnStock_Click)
{
datacon.getcom("delete from tb_stock where stockNum<=0");
MessageBox.Show("删除用户信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
我设了三个按钮,分别是查询三个表的内容并

申明一个全局变量:
private string tablename;

每次给datagridview绑定数据的时候更新这个变量tablename的值就好咯!

要想知道当前绑定的是哪个表!就知道访问变量tablename的值!