如何使用EmbeddedNavigator在DevExpress GridView中保存行更改 [英] How to save row changes in DevExpress GridView with the EmbeddedNavigator

查看:2093
本文介绍了如何使用EmbeddedNavigator在DevExpress GridView中保存行更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EmbeddedNavigator的Add,Edit和Remove按钮。我已经订阅了 gridControl1_EmbeddedNavigator_ButtonClick 事件,那里我检查点击了哪个按钮。

I am using the EmbeddedNavigator's Add, Edit and Remove buttons. I have subscribed to the gridControl1_EmbeddedNavigator_ButtonClick event and there I check which button is clicked.

问题是当我编辑单元格时,我按保存更改( EndEdit )我没有看到新的价值观。
这是我有的代码:

The problem is that when I edit a cell and I press save changes(EndEdit) I don't see the new values. Here is the code that I have:

private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
    if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.EndEdit)
            {
                if (MessageBox.Show("Do you want to save the changes?", "Save changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var rowHandle = gridView1.FocusedRowHandle;

                    // Here if the port is null by default, when I change it to 25
                    // I still get an empty string
                    var port = Convert.ToString(gridView1.GetRowCellValue(rowHandle, "ftpPort"));

                    var ftpConfig = new FtpConfiguration() { ftpPort = port };
                    // Update and save
                    context.UpdateFtpConfiguration(ftpConfig);
                    context.Save();
                }
                else
                    e.Handled = true;
            }
}

也许我必须先将它们追加到第一行,但是如何?

Maybe I have to append them to the row first, but how?

推荐答案

尝试将更改发布到底层的 DataSource 保存它:

Try to post your changes to underlying DataSource before saving it:

if (gridView1.IsEditing)
    gridView1.CloseEditor();

if (gridView1.FocusedRowModified)
    gridView1.UpdateCurrentRow();

这篇关于如何使用EmbeddedNavigator在DevExpress GridView中保存行更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆