ArgumentOutOfRangeException in OnLostFocus() when grid has read-only columns

7 posts, 0 answers
  1. Richard
    Richard avatar
    30 posts
    Member since:
    Oct 2010

    Posted 27 Jul 2011 Link to this post


    We recently upgraded to the Q2 2011 release (2011.2 712), and we began seeing exceptions from the RadGridView. This didn't happen with 2011.1 315. We're using a workaround, but we're not sure if the workaround has any negative side effects.

    Our app has a RadWindow pop-up containing a RadGridView. If the user is in the middle of an edit and they then click our Cancel button to close the RadWindow, the grid throws the following exception:

    System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. 
    Parameter name: index 
      at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args) 
      at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow) 
      at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell) 
      at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow) 
      at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit() 
      at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit() 
      at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus() 
      at Telerik.Windows.Controls.GridView.GridViewCell.OnLostFocus(RoutedEventArgs e) 
      at System.Windows.Controls.Control.OnLostFocus(Control ctrl, EventArgs e) 
      at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

    Our app code is not anywhere in this stack trace, so I don't think it's our bug.

    Here is the markup for our grid:

    <telerik:RadGridView Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" x:Name="gvUnderlyingGroupSymbols" ItemsSource="{Binding UnderlyingGroupSymbols}"
    AutoGenerateColumns="False" AlternationCount="2" ShowGroupPanel="False"
    SelectionMode="Extended" TabNavigation="Once" SelectionChanged="GvUnderlyingGroupSymbols_OnSelectionChanged" DataLoaded="GvUnderlyingGroupSymbols_DataLoaded" CanUserFreezeColumns="False"
    IsEnabled="{Binding AnUnderlyingGroupIsSelected}" >
            <telerik:GridViewDataColumn Header="Symbol" DataMemberBinding="{Binding SymbolCode}" IsReadOnly="True" />
            <telerik:GridViewDataColumn Header="Exchange" DataMemberBinding="{Binding ExchangeCode}" IsReadOnly="True" />
            <telerik:GridViewDataColumn Header="Type" DataMemberBinding="{Binding UnderlyingType}" IsReadOnly="True" />
                DataMemberBinding="{Binding Direction, Mode=TwoWay}"
            <telerik:GridViewDataColumn Header="Max Position" DataMemberBinding="{Binding MaxPosition}" DataFormatString="{}{0:N0}" TextAlignment="Right" />

    If we remove the read-only columns, the problem goes away.

    We found this earlier thread related to read-only columns: In that thread, Stefan Dobrev suggested suppressing errors from the grid using the following code:

    this.gridView.DataError += (s, args) => args.Handled = true;

    We tried this and it successfully prevents the exception. However, we're not sure if this also might suppress other problems that we'd actually like to know about. (Is this sort of like swallowing all exceptions with an empty 'catch' block? If so, it might hide some other bug.)

    Thanks for your help,

  2. Yordanka
    Yordanka avatar
    634 posts

    Posted 02 Aug 2011 Link to this post

    Hello Richard,

    I tried to reproduce the exception using the provided details but without any success. Could you isolate it in a sample project and send it to us so we can see what is going wrong? Thank you.
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. Tony
    Tony  avatar
    9 posts
    Member since:
    Feb 2011

    Posted 03 Aug 2011 Link to this post

    Hi Yordanka,

    Thanks for your help. We haven't had time yet to come up with a test project to reproduce the problem... we'll probably need to take our app and cut out everything except the problem part. For now, we've reverted to the old 2011.1 315 version, and that's working for us.

  4. Ronald
    Ronald avatar
    3 posts
    Member since:
    Jan 2010

    Posted 19 Aug 2011 Link to this post

    I also get the exception when editing a value in the grid:
    Specified argument was out of the range of valid values.
    Parameter name: index
       at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CanCellBecomeCurrent(GridViewCell cell)
       at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

    My Grid xaml looks like this:
    <telerikGridView:RadGridView x:Name="LanguagesGridView" Margin="0" d:LayoutOverrides="Width, Height" AutoGenerateColumns="False" CanUserFreezeColumns="False" IsFilteringAllowed="False" CellEditEnded="LanguagesGridView_CellEditEnded" CanUserDeleteRows="False" CanUserInsertRows="False" EditTriggers="CellClick" CanUserSelect="False" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Padding="0" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" BeginningEdit="LanguagesGridView_BeginningEdit" MinColumnWidth="150" RowIndicatorVisibility="Collapsed">







    I add the columns from code. I also have 2 readonly columns and set the FrozenColumnCount to 2
    I am using silverlight controls Q2 2011

    I can reproduce it in a test application, I will send it to you via a support ticket.

  5. Yordanka
    Yordanka avatar
    634 posts

    Posted 23 Aug 2011 Link to this post

    Hi Ronald,

    Please, check my reply in the other thread started by you.
    Kind regards,
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Chris
    Chris avatar
    1 posts
    Member since:
    Jul 2011

    Posted 17 Oct 2011 Link to this post

    I'm experiencing this same error as well.  I'm using v. 2001.2.920.1040.  What was your reply to Ronald's other thread?  Could you please post a link to it?

  7. Yordanka
    Yordanka avatar
    634 posts

    Posted 20 Oct 2011 Link to this post

    Hello Chris,

    The exception was related to the outdated Silverlight DataTable version. I am attaching a solution using more recent version of the Silverlight DataTable. Also, you may check this blog post for a reference.
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top