• GridView设置右键菜单


    一、控件设定:

    1.页面添加ContextMenuStrip控件;

    2.ContextMenuStrip添加菜单项;

    3.gridControl找到ContextMenuStrip属性,设置成刚添加ContextMenuStrip;

    二、代码实现:

    private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
            {
                try
                {
                    int intselect = gridView1.SelectedRowsCount;
                    MenuItemEdit.Enabled = false;
                    MenuItemDelete.Enabled = false;
                    if (intselect == 1)
                    {
                        MenuItemEdit.Enabled = true;
                        MenuItemDelete.Enabled = true;
                    }
                    else if (intselect > 1)
                    {
                        MenuItemEdit.Enabled = false;
                        MenuItemDelete.Enabled = false;
                    }
                }
                catch (Exception ex)
                {
                    app.Alert(ex.Message);
                }
            }
    
            private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                try
                {
                    if ((e.ClickedItem).Name == "MenuItemEdit")
                    {
                        OpenUpdateWin();
                    }
                    else if ((e.ClickedItem).Name == "MenuItemDelete")
                    {
                        DoDelete();
                    }
                }
                catch (Exception ex)
                {
                    app.Alert(ex.Message);
                }
            }
    

     原文引用:https://blog.csdn.net/jiankunking/article/details/46316973

  • 相关阅读:
    sql
    Java 反射
    Java 泛型
    Java 数组小记
    Java 实现二叉树
    Maven的环境配置
    用于解决easui 保存时候,前台传参是空字符串不null
    SpringMVC
    SpringMVC
    解决MySql varchar类型的数字排序
  • 原文地址:https://www.cnblogs.com/superelement/p/11765193.html
Copyright © 2020-2023  润新知