C# contextMenuStrip 使用例子

C# contextMenuStrip 使用例子_第1张图片
截图00.png
   public void DgvInstoreMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (e.RowIndex >= 0)
                {
                    //若行已是选中状态就不再进行设置
                    if (this.View.DgvInstore.DgvPageView.Rows[e.RowIndex].Selected == false)
                    {
                        this.View.DgvInstore.DgvPageView.ClearSelection();
                        this.View.DgvInstore.DgvPageView.Rows[e.RowIndex].Selected = true;
                    }
                    ////只选中一行时设置活动单元格
                    //if (this.View.DgvInstore.DgvPageView.SelectedRows.Count == 1)
                    //{
                    //    this.View.DgvInstore.DgvPageView.CurrentCell = this.View.DgvInstore.DgvPageView.Rows[e.RowIndex].Cells[e.ColumnIndex];
                    //}
                    //弹出操作菜单
                    this.InStoreID = Convert.ToInt32( this.View.DgvInstore.DgvPageView.Rows[e.RowIndex].Cells[0].Value.ToString());
                    this.View.MenuStrip.Show(Control.MousePosition.X, Control.MousePosition.Y);
                }
               
            }
        }
 public void MenuItem2Click(object sender,EventArgs e)
        {
            if (this.InStoreID == 0)
            {
                this.View.ShowTips("请选中一行信息");
            }
            else
            {
                frmInstorePresenter frm = new frmInstorePresenter(new frmInstore(), LocalClientProxy.PROTOCAL.NET_TCP, _address, _userId, _depId, _cmstId, storagename, device, this.InStoreID);
                frm.View.ShowDialog();
            }


        }

你可能感兴趣的:(C# contextMenuStrip 使用例子)