zoukankan      html  css  js  c++  java
  • datagridview右键菜单鼠标当前所在数据行进行选中,并在无数据时不显示右键菜单。

    View Code
     1         private void DgvConsignmentBills_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
     2         {
     3             if (e.Button == MouseButtons.Right)
     4             {
     5                 if (e.RowIndex >= 0)
     6                 {
     7                     this.DgvConsignmentBills.ClearSelection();
     8                     this.DgvConsignmentBills.Rows[e.RowIndex].Selected = true;
     9                     this.DgvConsignmentBills.CurrentCell = this.DgvConsignmentBills.Rows[e.RowIndex].Cells[e.ColumnIndex];
    10                     contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
    11                 }
    12             } 

    注意:使用次代码需要江datagridview的关联右键菜单去掉。不要在设计器中进行设计。

  • 相关阅读:
    队列
    栈的链式存储
    单例和多例设计模式
    顺序栈的基本操作
    串的模式匹配
    线性表的链式存储结构
    倒置顺序表
    回文序列
    go语言系列-从运算符到函数
    go语言系列-从零到数据类型
  • 原文地址:https://www.cnblogs.com/angels/p/2226623.html
Copyright © 2011-2022 走看看