DataGridView中实现右击选中当前行功能,并通过ContextMenuStrip获取当前行
2012-09-18 16:00
519 查看
2012-09-18
添加cell mouse down事件.
测试效果,正确的alert行号
添加cell mouse down事件.
private void gvShow_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { gvShow.ClearSelection(); gvShow.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; gvShow.CurrentCell = gvShow.Rows[e.RowIndex].Cells[e.ColumnIndex]; } }
测试效果,正确的alert行号
private void TestToolStripMenuItem_Click(object sender, EventArgs e) { string str = gvShow.CurrentCell.RowIndex.ToString(); MessageBox.Show(str); }
相关文章推荐
- <转>通过反射获取Form/MenuStrip/ContextMenuStrip等列表
- jQuery实现的全选、反选和获取当前所有选中的值功能
- iOS WebView 如何通过js获取网页中所有图片并加入点击事件,实现浏览图片的功能
- 通过SlidingMenu Viewpager实现当前最流行的侧滑[二]
- BootStrap Table复选框默认选中功能的实现代码(从数据库获取到对应的状态进行判断是否为选中状态)
- CListCtrl控件实现点击单行选中当前CheckBox点击CheckBox实现多选功能
- java实现获取当前日期所在的四个周的周日的功能,其中当前日期的周日是第三个,第四个是下周周日
- ContextMenuStrip右键菜单 获取关联控件、判断点击
- 通过SlidingMenu+Viewpager实现当前最流行的侧滑
- jQuery实现select下拉框获取当前选中文本、值、索引
- java实现记事本基本功能:新建、打开、保存、另存为、退出、替换、全部替换、复制、剪切、粘贴、全选、获取当前时间日期、修改字体、颜色、自动换行等
- Android实例:通过SlidingMenu Viewpager实现当前最流行的侧滑
- jQuery插件zTree实现获取当前选中节点在同级节点中序号的方法
- 通过广播方式获取当前网络类型,如果是Wifi,获取对应的信息(附加有root之后可实现保存的无线网名称及密码获取)
- c#中contextMenuStrip与datagridview使用CellMouseDown事件及treeview使用mousedown事件
- 通过委托实现--主窗体DataGridView上选中数据,刷新子窗体上对应的各值
- @SpringContext通过实现ApplicationContextAware接口动态获取bean
- BootStrap Table复选框默认选中功能的实现代码(从数据库获取到对应的状态进行判断是否为选中状态)
- 关于通过发送广播实现当前账号退出登录功能时需要注意的一些
- 通过脚本_spPageContextInfo获取当前SharePoint上下文信息