devExpress之旅xtraGrid新增行

gridView1.AddNewRow();

在没有保存之前失去焦点,则不能再回去!什么原因?

鼠标点击,不再处于编辑状态!

已有数据的情况下新增也是这样,无法再激活

源于我的代码:

private void gridView1_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)

{

if (!(_state==state.查看 || _state==state.排序))

{

//XtraMessageBox.Show("正处在编辑状态", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

e.Allow = false;

}

}

但为什么编辑状态下能很好的控制,而新增行的时候不能很好的控制焦点行呢?

跟踪发现,有新增行的时候,新增行一旦失焦,感觉有一个未知的行得到焦点!

只能换一种方法了:

//gridView1.AddNewRow();

Domain_SYSCODE domain = new Domain_SYSCODE();

_bindingSource.Add(domain);

_bindingSource.ResetBindings(false);

_bindingSource.MoveLast();

editStateControlEnabled(state.新增);

原文地址:https://www.cnblogs.com/goldarch/p/2048484.html