我正在使用DevExpress.XtraGrid GridView for WinForms,我不知道为什么下面的代码会抛出这个异常:
发生了'DevExpress.Utils.HideException'类型的异常 DevExpress.XtraEditors.v13.1.dll但未在用户代码中处理
堆栈追踪:
at DevExpress.XtraEditors.Container.ContainerHelper.OnInvalidValueException(IWin32Window owner,Exception sourceException,Object fValue) 在DevExpress.XtraGrid.Views.Base.ColumnView.SetRowCellValueCore(Int32 rowHandle,GridColumn列,Object _value,Boolean fromEditor) 在DevExpress.XtraGrid.Views.Grid.GridView.SetRowCellValueCore(Int32 rowHandle,GridColumn列,Object _value,Boolean fromEditor) 在DevExpress.XtraGrid.Views.Grid.GridView.PostEditor(Boolean causeValidation) 在DevExpress.XtraGrid.Views.Base.BaseView.CloseEditor(Boolean causeValidation) 在DevExpress.XtraGrid.Views.Base.ColumnView.CheckCanLeaveRow(Int32 currentRowHandle,Boolean raiseUpdateCurrentRow) 在DevExpress.XtraGrid.Views.Grid.GridView.DoChangeFocusedRow(Int32 currentRowHandle,Int32 newRowHandle,Boolean raiseUpdateCurrentRow) 在DevExpress.XtraGrid.Views.Base.ColumnView.DoChangeFocusedRowInternal(Int32 newRowHandle,Boolean updateCurrentRow) 在DevExpress.XtraGrid.Views.Base.ColumnView.set_FocusedRowHandle(Int32值) at xyzForm.gridView_MouseDown(Object sender,MouseEventArgs e)in c:... xyzForm.cs:line 1218 在DevExpress.XtraGrid.Views.Base.BaseView.RaiseMouseDown(MouseEventArgs e) 在DevExpress.XtraGrid.Views.Base.Handler.BaseViewHandler.OnMouseDown(MouseEventArgs e) 在DevExpress.XtraGrid.Views.Grid.Handler.GridHandler.OnMouseDown(MouseEventArgs ev) 在DevExpress.Utils.Controls.BaseHandler.ProcessEvent(EventType etype,Object args) 在DevExpress.XtraGrid.Views.Base.Handler.BaseViewHandler.ProcessEvent(EventType etype,Object args) 在DevExpress.XtraGrid.GridControl.OnMouseDown(MouseEventArgs ev)
代码(简化):
private void gridView_MouseDown(object sender, MouseEventArgs e)
{
GridHitInfo info = gridView.CalcHitInfo(e.Location);
if (info.Column == null) return;
gridView.FocusedRowHandle = info.RowHandle; // this line throws
gridView.FocusedColumn = info.Column;
}
这里gridView.FocusedRowHandle
是一个int(当前值为4),info.RowHandle
也是一个int(值为5)。 GridView有20行。
答案 0 :(得分:2)
据我所知,当您在编辑器验证未完成时尝试更改焦点行时,GridControl会抛出此异常,因为在验证编辑器中输入正确的值之前,GridControl不允许任何操作。并且不需要在用户代码中对此异常执行某些操作,因为此异常应由GridControl本身处理,而不会影响您的应用程序。
我相信您应该直接与DevExpress Support小组联系以澄清情况。