加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 在winform应用程序的数据网格视图中添加上下文菜单

发布时间:2020-12-15 04:13:05 所属栏目:百科 来源:网络整理
导读:右键单击DataGridView中的菜单项时如何显示上下文菜单? 我想在菜单中添加删除,以便删除整行. 提前致谢 解决方法 参考米格尔的答案 我认为这样很容易实现 int currentRowIndex; private void dataGridView1_CellMouseUp(object sender,DataGridViewCellMouse
右键单击DataGridView中的菜单项时如何显示上下文菜单?
我想在菜单中添加删除,以便删除整行.
提前致谢

解决方法

参考米格尔的答案
我认为这样很容易实现
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]);
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读