简体   繁体   中英

ArgumentOutOfRangeException is thrown in silverlight DataGrid after clicking the Enter button in c#

I was trying to update some cell in the datagrid(silverlight),if i am clicking the "ENTER" key in the keyboard once making the cell value to zero.I am getting the error ArgumentOutOfRangeException.That also in page I am not receiving any error but suddenly it thrown unhandled exception.

the scenario is once I am updating some value in the particular cell(in one row) then the remaining cell values from the other rows should be altered..

The following is the detailed error ..

Error: Unhandled Error in Silverlight Application Code: 4004
Category: ManagedRuntimeError
Message: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Parameter name: index

at System.Windows.Data.PagedCollectionView.GetItemAt(Int32 index)

at System.Windows.Controls.DataGridDataConnection.GetDataItem(Int32 index)

at System.Windows.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot)

at System.Windows.Controls.DataGrid.InsertDisplayedElement(Int32 slot, Boolean updateSlotInformation)

at System.Windows.Controls.DataGrid.GetExactSlotElementHeight(Int32 slot)

at System.Windows.Controls.DataGrid.ScrollSlotIntoView(Int32 slot, Boolean scrolledHorizontally)

at System.Windows.Controls.DataGrid.ScrollSlotIntoView(Int32 columnIndex, Int32 slot, Boolean forCurrentCellChange, Boolean forceHorizontalScroll)

at System.Windows.Controls.DataGrid.ProcessSelectionAndCurrency(Int32 columnIndex, Object item, Int32 backupSlot, DataGridSelectionAction action, Boolean scrollIntoView)

at System.Windows.Controls.DataGridDataConnection.CollectionView_CurrentChanged(Object sender, EventArgs e)

at System.Windows.Data.PagedCollectionView.OnCurrentChanged()

at System.Windows.Data.PagedCollectionView.MoveCurrentToPosition(Int32 position)

at System.Windows.Data.PagedCollectionView.MoveCurrentTo(Object item)

at System.Windows.Controls.DataGridDataConnection.MoveCurrentTo(Object item, Int32 backupSlot, Int32 columnIndex, DataGridSelectionAction action, Boolean scrollIntoView)

at System.Windows.Controls.DataGrid.UpdateSelectionAndCurrency(Int32 columnIndex, Int32 slot, DataGridSelectionAction action, Boolean scrollIntoView)

at System.Windows.Controls.DataGrid.ProcessDownKeyInternal(Boolean shift, Boolean ctrl)

at System.Windows.Controls.DataGrid.ProcessEnterKey(Boolean shift, Boolean ctrl)

at System.Windows.Controls.DataGrid.<>c__DisplayClass17.b__14()

at System.Windows.Controls.DataGrid.EditingElement_LostFocus(Object sender, RoutedEventArgs e)

at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)

at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags

Any one can please help me out to get rid of this issue.. Thanks in Advance.

You have to check the property that the cell is bound to. As the error message says you are passing a value that is out of range. Apparently it must be greater then 0 (zero). Or you have to prevent the user from entering invalid values with by validating the input... or as last resort change the propeperty's condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM