您的位置:首页 > 其它

winform datagridview 通过右键菜单来删除数据行

2011-09-06 00:02 281 查看
1.实现当鼠标移到数据行时,右键删除数据。

步骤1.先定义变量CurrentRowIndex来存储鼠标经过的行数。

如下:

View Code 1 private void dataGridView1_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
2 {
3 if (!isLoad)
4 {
5 if (MessageBox.Show(
6 "确定要删除数据吗?",
7 "删除确认",
8 MessageBoxButtons.OKCancel,
9 MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) == DialogResult.OK
)
{
int removeIndex = e.RowIndex;
// string removeColumnOneText = Convert.ToString(dataGridView1[0,e.RowIndex].Value);
MessageBox.Show("你的数据被删除了:" + removeIndex);
}

}

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