添加上下文菜单在数据网格视图在WinForm应用程序 [英] Add context menu in a datagrid view in a winform application

查看:94
本文介绍了添加上下文菜单在数据网格视图在WinForm应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示上下文菜单当你右键点击菜单项中的一个DataGridView? 我想补充的菜单中删除,使整个行可以删除。 在此先感谢

How to show a Context Menu when you right click a Menu Item in a DataGridView ? I would like to add delete in the menu so that the entire row can be deleted . Thanks in Advance

推荐答案

参照米格尔答案
我认为这将是很容易实现这样的

With reference to Miguel answer
I think this will be easy to implement like this

    int currentRowIndex;
    private void dataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
    {
        currentRowIndex = e.RowIndex;
    }  
    private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
    {    
        dataGridView1.Rows.Remove(dataGridView1.Rows[currentRowIndex]);
    }

这篇关于添加上下文菜单在数据网格视图在WinForm应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆