gpt4 book ai didi

c# - 如何使用 EmbeddedNavigator 在 DevExpress GridView 中保存行更改

转载 作者:行者123 更新时间:2023-11-30 20:46:35 26 4
gpt4 key购买 nike

我正在使用 EmbeddedNavigator 的添加、编辑和删除按钮。我已经订阅了 gridControl1_EmbeddedNavigator_ButtonClick 事件,我在那里检查单击了哪个按钮。

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

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;
}
}

也许我必须先将它们附加到行中,但是如何呢?

最佳答案

尝试在保存之前将您的更改发布到底层 DataSource:

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

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

关于c# - 如何使用 EmbeddedNavigator 在 DevExpress GridView 中保存行更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26712497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com