如何退出编辑模式

时间:2019-01-03 21:48:14

标签: c# winforms gridview event-handling dotnetbar

我有一个网格视图(dotnetbar中的超级网格),该视图具有上下文菜单条以删除一行。单击单元格后,gridview进入编辑模式。一旦上下文菜单选项完成了删除操作,我就需要使网格脱离编辑模式。

这是gridview进入编辑模式的方式:

   private void superGrid1_CellClick(object sender, GridCellClickEventArgs e)
    {
        superGrid1.PrimaryGrid.KeyboardEditMode = KeyboardEditMode.EditOnKeystroke;
        superGrid1.PrimaryGrid.MouseEditMode = MouseEditMode.SingleClick;
    }

这是删除行的代码:

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
    {
        try
        {
            var i = superGrid1.GetSelectedElements();
            if (i.Count > 0)
            {
                if (MessageBox.Show("Do you want to delete this row?", "confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    superGrid1.PrimaryGrid.Rows.Remove(i[0]);
                    superGrid1.PrimaryGrid.PurgeDeletedRows();
                    superGrid1.PrimaryGrid.DataSource = mBatchData;
                    gridDataChanged = true;
                }
            }
            else
            {
                //do nothing.
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            //this is where the grid needs to get out of the edit mode
        }

    }

0 个答案:

没有答案
相关问题