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);
}
}
}
步骤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);
}
}
}
相关文章推荐
- 删除 QQ 最新版右键菜单 通过QQ发送文件到手机
- 如何从右键弹出菜单中清空删除数据加清空前提问确定
- C# winform datagridview中如何实现鼠标右键点击一行数据出现一个带有删除的菜单,并能执行删除操作?
- 稳扎稳打Silverlight(57) - 4.0通信之WCF RIA Services: 概述, 通过 DomainDataSource 实现数据的添加、查询、更新和删除操作
- 稳扎稳打Silverlight(57) - 4.0通信之WCF RIA Services: 概述, 通过 DomainDataSource 实现数据的添加、查询、更新和删除操作
- 删除鼠标右键菜单多余选项的方法
- 删除核心显卡右键菜单
- 删除百度云右键菜单
- 稳扎稳打Silverlight(58) - 4.0通信之WCF RIA Services: 通过 Domain Service, 以 MVVM 模式实现数据的添加、删除、修改和查询
- 通过游标删除重复数据
- 删除右键菜单上的Adobe Drive CS4,Win7上也没有问题
- Window XP 增加自己喜欢的右键菜单和删除不需要的菜单
- [Visual Studio] 开启Visual Studio 2012通过右键菜单创建单元测试(Unit Test)
- 【mongo】pymongo通过_id删除数据
- 【第26篇】通过Gson解析微信自定义菜单多个Button的数组数据
- SQLServer通过链接服务器远程删除数据性能问题解决
- solr通过http请求删除数据
- 删除右键新建菜单中的多余项
- 删除右键菜单
- 通过loadrunner 11常规通用的C语言API类型的Vuser 方式,测试验证MySQL数据库插入、查询、修改、删除数据性能脚本实例