dataGridView右键菜单并选中该行

程序代码:

private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (e.RowIndex >= 0)
{
dataGridView1.ClearSelection();
dataGridView1.Rows[e.RowIndex].Selected = true;
dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
}
}
} 去掉带*好的左边的那一列: 把DataGridView 的RowHeadervisible设置成false

WinFrom - DataGridView控件右键选中记录并弹出菜单的更多相关文章

  1. DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体

    弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...

  2. 2015.2.16 关于delphi web控件打开新网页时弹出关闭页面(js代码)出错的解决办法研究

    参考网址1:http://www.csharpwin.com/csharpspace/2360.shtml...参考网址2:http://www.oschina.net/question/234345 ...

  3. C# ie通过打印控件点打印,总是弹出另存为xps的对话框

    用的是lodop打印控件,点打印后,总是弹出另存为xps的对话框,后来在网上查到可能是把windows自带的Microsoft XPS Document Writer设为默认打印机的原因. 但现在没有 ...

  4. 变相的取消Datagridview控件的选中状态

    思路:把每一列的文字颜色设为黑色,选中时候的背景为白色,颜色为黑色.每一列都这样设置,那么变相的达到了取消选中效果. 图:

  5. C# winfrom Datagridview控件下拉菜单

    拖拽一个datagridview放在界面,编辑列把下来菜单那列ColumnType设置成DataGridViewComboBoxColumn 然后在数据一栏的Items可以写下来菜单的内容也可以后台代 ...

  6. [js开源组件开发]js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器

    js dialog组件,包含alert和confirm的实现 本组件所有的资源均在github上可以查看源代码 GitHub 本dialog的组件的例子请在这里查看 demo dialog js di ...

  7. datagridview 右键选中行 并弹出菜单

    private void dataGridView_OLUsers_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { i ...

  8. listview点击控件显示EditText,键盘弹出消失的解决方法:

    1.软键盘弹出后消失解决方法 AndoridManifet 在activity中添加: android:windowSoftInputMode="adjustPan" 2.使用方式 ...

  9. AngularJS页面【uib-dropdown】控件在模态窗口(弹出窗)中无法使用问题

    如果你的下拉框中有属性 dropdown-append-to-body 将它去掉,即可正常使用该插件. <div class="btn-group dropdown" uib ...

随机推荐

  1. STL 源代码剖析 算法 stl_algo.h -- partition

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie partition ------------------------------------ ...

  2. BZOJ 1798: [Ahoi2009]Seq 维护序列seq( 线段树 )

    线段树.. 打个 mul , add 的标记就好了.. 这个速度好像还挺快的...( 相比我其他代码 = = ) 好像是#35.. ---------------------------------- ...

  3. 一个库搞定各种分享--ShareSDK

    ShareSDK是为iOS.Android.WindowsPhone提供社会功能的一个组件,开发者只需10分钟即可集成到自己的APP中,它不仅支持分享给QQ好友.微信好友.微信朋友圈.新浪微博.腾迅微 ...

  4. Linux如何修改SSH端口号

    SSH是什么? SSH 为 Secure Shell 由 IETF 的网络工作小组(Network Working Group)所制定: SSH 是建立在应用层和传输层基础上的一种安全协议. SSH传 ...

  5. PyQt中如何隐藏Menu

    PyQt中隐藏一个Menu Item,可以通过QAction的setVisible(False)来设置,而QMenu的setVisible(False)是不管用的. 现在问题来了,我们有一个菜单,它有 ...

  6. json文件问题

    在json数据没有错误 字符 的前提下  出现的问题 如果有中文 那么编码格式 必须是UTF-8格式的

  7. Week1(9月12日):很激动的第一次课

    Part I:课程介绍  =========================== 1. 学时 8*16=128 2. 时间 周二1234,周五1234 3. 地点 E307 4. 考试方式 笔试+上机 ...

  8. mysql not in、left join、IS NULL、NOT EXISTS 效率问题记录

    原文:mysql not in.left join.IS NULL.NOT EXISTS 效率问题记录 mysql not in.left join.IS NULL.NOT EXISTS 效率问题记录 ...

  9. lua序列化table表到文件中

    先上代码 function luautil.serialize(t, sort_parent, sort_child) local mark={} local assign={} local func ...

  10. UVA1452|LA4727-----Jump------经典的约瑟夫公式的变形(DP)

    本文出自:http://blog.csdn.net/dr5459 题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&a ...