This is a migrated thread and some comments may be shown as answers.

Exception thrown when user double clicks on column header to size column to fit content

2 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 18 Jul 2012, 03:50 PM
My boss just showed this to me, though it's been in the application for a while.  If a user double clicks on the divider between columns in the column header on this one RadGridView control in my app, the following exception is thrown:

2012-07-18 09:11:18,106 [1] FATAL CarSystem.App [(null)] -  Invalid value!
Parameter name: value
  
   at Telerik.Windows.Controls.GridViewLength..ctor(Double value, GridViewLengthUnitType type, Double desiredValue, Double displayValue)
   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnColumnHeaderGripperDragCompleted(Object sender, DragCompletedEventArgs e)
   at System.Windows.Controls.Primitives.DragCompletedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.Thumb.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Here is the XAML for the RadGridView in question:

<telerik:RadGridView AutoExpandGroups="True"
                     AutoGenerateColumns="False"
                     CanUserDeleteRows="False"
                     CanUserFreezeColumns="False"
                     CanUserInsertRows="False"
                     CanUserResizeColumns="True"
                     CanUserSortColumns="True"
                     EnableColumnVirtualization="True"
                     EnableRowVirtualization="True"
                     FontSize="16"
                     FontWeight="Bold"
                     IsReadOnly="True"
                     MouseDoubleClick="HotListEntriesGrid_MouseDoubleClick"
                     Name="HotListEntriesGrid"
                     SelectionChanged="HotListEntriesGrid_SelectionChanged"
                     SelectionUnit="FullRow"
                     ScrollViewer.CanContentScroll="True"
                     ScrollViewer.HorizontalScrollBarVisibility="Auto"
                     ScrollViewer.VerticalScrollBarVisibility="Auto"
                     ToolTip="Matching Hot List Entries">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Plate,        Mode=OneWay}"
                                    Header="Plate"
                                    Width="1.5*" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LocaleCode, Mode=OneWay}"
                                    Header="State"
                                    Width="75" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ListName,   Mode=OneWay}"
                                    Header="Hot List"
                                    Width="150" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding AlarmClass, Mode=OneWay}"
                                    Header="Alarm Class"
                                    Width="175" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Notes,     Mode=OneWay}"
                                    Header="Notes"
                                    Width="1*" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

With some experimenting, I've found that the exception is thrown only if you click on those columns that contain "*" in their Widths.  if you set it to Auto or a fixed value, it doesn't happen.

Tony

2 Answers, 1 is accepted

Sort by
0
Vera
Telerik team
answered on 18 Jul 2012, 04:11 PM
Hello Tony,

 
I tried to reproduce the issue you reported but I was not able to. Attached you can find the project used for the test. Are you able to get the described problem on it? Is there something I am missing?

Regards,
Vera
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tony
Top achievements
Rank 1
answered on 18 Jul 2012, 05:13 PM
The most obvious thing that's different is you're using version 2012.2.607.40, but I'm using 2012.1.326.40.  Sorry, I should have included that in the original post.

However, even when I change over to the versions of the Telerik DLLs I'm using, the issue doesn't happen in your sample. 

Further, I tried copying over the custom templates I'm using for the RadGridView and GridViewRow types and that didn't do it, either.

I also tried adding the ThemeSelector class I'm using, along with the ResourceDictionaries for Day Mode and Night Mode, and that had no effect.

However, after more experimenting, apparently the problem turns to be related to my MouseDoubleClick event handler.  I made a change in there to keep it from doing what it's supposed to do if the SelectedItem property of the RadGridView is null and the issue went away.

Thank you for your help, anyway.

Tony
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Vera
Telerik team
Tony
Top achievements
Rank 1
Share this question
or