您的位置:首页 > 其它

给DataGridView 添加鼠标单击事件,并且在contexMenutstrip中显示,获取该行的主键

2015-04-09 08:52 405 查看
   private void dataGridViewEx1_MouseClick(object sender, MouseEventArgs e)

        {

            if(e.Button==MouseButtons.Right)

            {

                contextMenuStrip3.Show(dataGridViewEx1, 0, e.Y);
            }

        }
        private void toolStripMenuItem_Delete_Click(object sender, EventArgs e)

        {

            if(MessageBox.Show("确定要删除该条记录吗?","提示",MessageBoxButtons.YesNo)==DialogResult.Yes)  //messbox的show方法的使用

            {

                int MXid = DbUtils.GetInt(dataGridViewEx1.CurrentRow.Cells[0].Value.ToString());      
//右键点击所在的行

                DAL.TorchLabQuery.DeleteMXid(MXid);

            }

            BindGridMX(tb_RN.Text);

        }

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐