Error Message is "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
Stack trace is as follows:
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Telerik.WinControls.UI.StretchColumnLayoutHelper.ResizeColumn(Int32 delta)
at Telerik.WinControls.UI.TableViewRowLayout.ResizeColumn(Int32 delta)
at Telerik.WinControls.UI.TableViewRowLayout.StretchColumn(GridViewColumn column, Int32 desiredWidth)
at Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth)
at Telerik.WinControls.UI.BestFitHelper.BestFitColumnsCore()
at Telerik.WinControls.UI.BestFitHelper.ProcessRequests()
at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridViewTemplate.FireViewChangedEvent(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
at Telerik.WinControls.UI.GridViewTemplate.BestFitColumns()
at HBS.Scanesthesia.WinForms.MainForm.SelectedPageChanged(Object sender, EventArgs e) in C:\Users\bschultz\Documents\Visual Studio 2010\Projects\Scanesthesia\HBS.Scanesthesia.Forms\MainForm.cs:line 267
at HBS.Scanesthesia.WinForms.MainForm.ShownForm(Object sender, EventArgs e) in C:\Users\bschultz\Documents\Visual Studio 2010\Projects\Scanesthesia\HBS.Scanesthesia.Forms\MainForm.cs:line 48
at System.Windows.Forms.Form.OnShown(EventArgs e)
at System.Windows.Forms.Form.CallShownEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
Any ideas? Has this changed some how from Q3 -> SP1?
35 Answers, 1 is accepted
I haven't been able to replicate your issue. Are you able to provide a small, simple exmaple of a grid view where I can replicate this to look into it for you?
thanks
Richard
However, it happens only for one particular gridview. I deleted it, recreated it, attached the datasource, it worked fine until I clicked the best fit columns and here we go again, the grid is screwed..
thanks
I still haven't been able to replicate this at the moment, but it sounds quite sporadic. I added a RadGridView, added some columns through the property builder, set the AutoSizeColumnMode to fill and then on the Smart Tag, hit BestFitColumns.
regards,
Richard
I've noticed this problem also, but only when inside a BeginUpdate() / EndUpdate(), if you are calling this from within, please try addin the BestFitColumns() after the EndUpdate().
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
but like you said, it is very sporadic. I only have one problematic grid out of 200... but something is causing that for sure and deleting and recreating the grid does not help..
thanks for trying
And you are calling the BestFitColumns in the DataBindingComplete event? And can you please tell me if you are using BeginUpdate() / EndUpdate() or DeferRefresh()?
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Private Sub co_pnl_Payables_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
RadGridLocalizationProvider.CurrentProvider = New Controls.FrenchRadControls.RadGridView
ChargerPayables() 'I load the dataset here
SetInitialFilters(dgPayable)
dgPayable.BestFitColumns()
dgPayable.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
LoadLayout(Me.Name + "." + dgPayable.Name, dgPayable, CalculMenuStrip)
Catch ex As Exception
End Try
End Sub
Like I said, the problem also occur when you click BestFitColumn in the designer.. only when AutoSizeColumnMode=Fill
Thanks guys
Please don't do that, please register for the DataBindingComplete event before setting the datasource, and fire the BestFitColumns() in the DataBindingComplete event and let me know if this solved your problem
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I will try and let you know
If I set the autosizecolumnmode to None, then there's no problem with the BestFitColumn in the DataBindingComplete. However, if I set the autosizecolumnmode to Fill, I cannot even load the form, I get the error message when I fire the form.show event.
More details to come if needed, I got to go.
thanks
Worst, I copied and pasted the grid on top of the problematic one (so it should react the same way...) and I was able to group by column, but still can't hide/show. Another weird behaviour, when I right-click on the newly created grid using my custom contextmenu, it shows it no problem but once I clicked on an item, it shows another contextmenu that is not even in the form... wow.
I don't know what else to check..
The reason I suspect you are getting the more than one action after clicking on your context menu is that you are manually adding event handlers in the ContextMenuOpening event for your click event. Each time you open the context menu you are creating the event handler on top of the one that already exists and therefore the click event is firing +1 times each time you open the context menu.
Either remove the handler before adding it, or move this code out of the ContextMenuOpening event
Regards,
Richard
Ok, can someone please post a full example so we can find a solution to this problem? Like i said the only problems I've been experiencing is that with the BestFitColumns() inside BeginUpdate / EndUpdate.
Best Regards,
Emanuel Varga
Telerik WinForms MVP
On a side note, above mentions running BestFitColumns on DataBindingComplete. Is this just a best practice or a requirement(not in docuemtation). Also talks about calling on the MasterTemplate vs on the grid. Please clarify when BestFitColumns can be used.
b r a d
I will do some tests on my end and let you know
Emmanuel, personnaly I cannot provide a full exemple my project is way too big and complex.. I will try to find something else..
I can then call the AutoSizeColumnMode and set it to Fill, but most of the times I get various undesired behaviour.. (grid not being refreshed after grouping, filter row not working, BestFitColumns either give an error message index out of bound or the column width are badly calculted, etc.)
That being said, since it seems to happend on all my grids now, I will try to create a small project and send it to you all later today...
thanks
Just to contribute, this is the first time I've also experienced now an issue with BestFit. Here is my stack trace.
Object reference not set to an instance of an object.
at Telerik.WinControls.UI.StretchColumnLayoutHelper.StartColumnResize(GridViewColumn column)
at Telerik.WinControls.UI.TableViewRowLayout.StartColumnResize(GridViewColumn column)
at Telerik.WinControls.UI.TableViewRowLayout.StretchColumn(GridViewColumn column, Int32 desiredWidth)
at Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth)
at Telerik.WinControls.UI.BestFitHelper.BestFitColumnsCore()
at Telerik.WinControls.UI.BestFitHelper.ProcessRequests()
at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.Layouts.DockLayoutPanel.MeasureOverride(SizeF constraint)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.LightVisualElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.RootRadElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RootRadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.ComponentLayoutElementTree.PerformInnerLayout(Boolean performMeasure, Int32 x, Int32 y, Int32 width, Int32 height)
at Telerik.WinControls.RadControl.GetInitialDesiredSize(Size availableSize, Boolean useNewLayoutSystem)
at Telerik.WinControls.RadControl.OnLoad(Size desiredSize)
at Telerik.WinControls.RadControl.LoadElementTree(Size desiredSize)
at Telerik.WinControls.RadControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at Telerik.WinControls.UI.RadPageViewPage.set_Visible(Boolean value)
at Telerik.WinControls.UI.RadPageViewElement.SetSelectedContent(RadPageViewItem item)
at Telerik.WinControls.UI.RadPageViewElement.SetSelectedItem(RadPageViewItem item)
at Telerik.WinControls.UI.RadPageViewElement.OnSelectedPageChanged(RadPageViewEventArgs e)
at Telerik.WinControls.UI.RadPageView.SetSelectedPage(RadPageViewEventArgs e)
at Telerik.WinControls.UI.RadPageView.set_SelectedPage(RadPageViewPage value)
at Telerik.WinControls.UI.RadPageViewElement.SelectItem(RadPageViewItem item)
at Telerik.WinControls.UI.RadPageViewElement.OnItemMouseDown(RadPageViewItem sender, MouseEventArgs e)
at Telerik.WinControls.UI.RadPageViewStripElement.OnItemMouseDown(RadPageViewItem sender, MouseEventArgs e)
at Telerik.WinControls.UI.RadPageViewItem.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadControl.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at Telerik.WinControls.RadNCEnabledControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Richard
Ok, in a new project I can replicate this every time now. The problem is a mixture of two things.
In order to replicate this you need to have
- AutoSizeColumnsMode set to Fill AND
- Have at least one GroupDescriptor
See the following code: Either change the code to remove the GroupDescriptor or, change to None for AutoSizeColumnsMode and BestFit works fine.
(this is a RadGridView and a RadButton on a RadForm)
Imports
Telerik.WinControls.UI
Imports
System.ComponentModel
Imports
Telerik.WinControls.Data
Public
Class
Form1
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
Me
.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
Me
.RadGridView1.EnableGrouping =
True
Me
.RadGridView1.ShowGroupPanel =
False
Dim
people
As
New
BindingList(Of Person)
people.Add(
New
Person(
"Richard"
, 40,
False
))
people.Add(
New
Person(
"Peter"
, 104,
True
))
people.Add(
New
Person(
"Chris"
, 43,
False
))
people.Add(
New
Person(
"Oliver"
, 12,
False
))
Try
Me
.Cursor = Cursors.WaitCursor
Me
.RadGridView1.BeginUpdate()
Me
.RadGridView1.DataSource =
Nothing
Me
.RadGridView1.DataSource = people
Me
.RadGridView1.GroupDescriptors.Clear()
Dim
descriptor
As
New
GroupDescriptor()
descriptor.GroupNames.Add(
"HasBeard"
, ListSortDirection.Ascending)
Me
.RadGridView1.GroupDescriptors.Add(descriptor)
Me
.RadGridView1.EndUpdate()
Finally
Me
.Cursor = Cursors.
Default
End
Try
End
Sub
Private
Sub
RadButtonBestFit_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButtonBestFit.Click
Me
.RadGridView1.BestFitColumns()
End
Sub
End
Class
Public
Class
Person
Public
Sub
New
(
ByVal
name
As
String
,
ByVal
age
As
Integer
,
ByVal
hasBeard
As
Boolean
)
Me
.Name = name
Me
.Age = age
Me
.HasBeard = hasBeard
End
Sub
Public
Property
Name
As
String
Public
Property
Age
As
Integer
Public
Property
HasBeard
As
Boolean
End
Class
Richard
@Richard: Thank you for your help in the forums.
@Marc-Andre: I did not manage to reproduce the issue with Richard's code snippet. I tried to experience it with Q3 2010 (2010.3 10.1109) and Q3 2010 SP1 (2010.3 10.1215). I would kindly ask you to open a support ticket with an attached project where the issue can be reproduced. This will allow us to investigate the case further.
Greetings,Svett
the Telerik team
I can send this on now as I have the project ready. I'll open a support ticket and include a video too.
Hope this helps
Richard
Just to let you know I've had a note that this is an issue that will be fixed in one of the upcoming releases. I understand that a workaround will be posted shortly.
Regards,
Richard
@Richard: Thank you for opening the support ticket.
@Bradley Schultz: You can use the following code snippet to work around this issue. The issue will be addressed in our next major release.
VB Version:
Public
Class
MyTableViewRowLayout
Inherits
TableViewRowLayout
Public
Overrides
Sub
StartColumnResize(
ByVal
column
As
GridViewColumn)
If
column.IsGrouped
AndAlso
(
Not
column.OwnerTemplate.ShowGroupedColumns)
Then
Return
End
If
MyBase
.StartColumnResize(column)
End
Sub
End
Class
Public
Class
MyTableViewDefinition
Inherits
TableViewDefinition
Public
Overrides
Function
CreateRowLayout()
As
IGridRowLayout
Return
New
MyTableViewRowLayout()
End
Function
End
Class
Me
.RadGridView1.ViewDefinition =
New
MyTableViewDefinition()
Dim
rowLayout
As
New
MyTableViewRowLayout()
rowLayout.Initialize(
Me
.RadGridView1.TableElement)
Me
.RadGridView1.TableElement.ViewElement.RowLayout = rowLayout
C# Version:
public
class
MyTableViewRowLayout : TableViewRowLayout
{
public
override
void
StartColumnResize(GridViewColumn column)
{
if
(column.IsGrouped && !column.OwnerTemplate.ShowGroupedColumns)
{
return
;
}
base
.StartColumnResize(column);
}
}
public
class
MyTableViewDefinition : TableViewDefinition
{
public
override
IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
return
base
.CreateViewUIElement(viewInfo);
}
public
override
System.Type RowLayoutType
{
get
{
return
typeof
(MyTableViewRowLayout);
}
}
public
override
IGridRowLayout CreateRowLayout()
{
return
new
MyTableViewRowLayout();
}
}
this
.radGridView1.ViewDefinition =
new
MyTableViewDefinition();
MyTableViewRowLayout rowLayout =
new
MyTableViewRowLayout();
rowLayout.Initialize(
this
.radGridView1.TableElement);
this
.radGridView1.TableElement.ViewElement.RowLayout = rowLayout;
I hope this helps.
Regards,
Svett
the Telerik team
Just an extra note so you can track this issue in PITS. the link is here
All the best
Richard
Unfortunately, I am not able to assist you following the supplied information. Could you open a support ticket with an attached project where the issue occurs?
Thank you for your cooperation.
All the best,
Svett
the Telerik team
InnerException: System.NotSupportedException
HResult=-2146233067
Message='RadGridDateTimeConverter' is unable to convert 'System.String' to 'System.DateTime'.
Any Ideas? This worked with the earlier version.
I am pivoting a Text Column and some of the dates may be null.
Thanks,
John
Full error msg:
System.Int32
A first chance exception of type 'System.FormatException' occurred in Telerik.WinControls.GridView.dll
Error 13: Converter cannot process the value with this parameters.
System.Reflection.TargetInvocationException was unhandled
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig,
Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters,
Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback
callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback
callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam,
IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent
Manager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext
context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at CryoInv.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line
81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[]
args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback
callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback
callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.FormatException
HResult=-2146233033
Message=Converter cannot process the value with this parameters.
Source=Telerik.WinControls.GridView
StackTrace:
at Telerik.WinControls.UI.RadDataConverter.ThrowFormatException(Exception ex, String
message)
at Telerik.WinControls.UI.RadDataConverter.Format(Object value, Type targetType, Boolean
coerceNullValue, IDataConversionInfoProvider converstionInfoProvider)
at Telerik.WinControls.UI.GridDataCellElement.ApplyFormatString(Object value)
at Telerik.WinControls.UI.GridDateTimeCellElement.ApplyFormatString(Object value)
at Telerik.WinControls.UI.GridCellElement.SetContentCore(Object value)
at Telerik.WinControls.UI.GridCellElement.SetContent()
at Telerik.WinControls.UI.GridVirtualizedCellElement.OnPropertyChanged
(RadPropertyChangedEventArgs e)
at Telerik.WinControls.RadObject.RaisePropertyNotifications(RadPropertyValue propVal, Object
oldValue, Object newValue, ValueSource oldSource)
at Telerik.WinControls.RadObject.ResetValueCore(RadPropertyValue propVal, ValueResetFlags
flags)
at Telerik.WinControls.RadObject.UnbindProperty(RadProperty boundProperty)
at Telerik.WinControls.UI.GridDataCellElement.UnbindColumnProperties()
at Telerik.WinControls.UI.GridVirtualizedCellElement.Detach()
at Telerik.WinControls.UI.GridDataCellElement.Detach()
at Telerik.WinControls.UI.GridVirtualizedRowElement.DetachCells()
at Telerik.WinControls.UI.GridDataRowElement.Detach()
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.UpdateElement(Int32 position, T data)
at Telerik.WinControls.UI.ScrollableRowsContainerElement.UpdateElement(Int32 position,
GridViewRowInfo data)
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureOverride(SizeF
availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureViewElement(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.Layouts.DockLayoutPanel.MeasureOverride(SizeF constraint)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.LightVisualElement.MeasureElements(SizeF availableSize, SizeF
clientSize, Padding borderThickness)
at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.RootRadElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RootRadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayoutCallback(ILayoutManager
manager)
InnerException: System.NotSupportedException
HResult=-2146233067
Message='RadGridDateTimeConverter' is unable to convert 'System.String' to
'System.DateTime'.
Source=System
StackTrace:
at System.ComponentModel.TypeConverter.GetConvertToException(Object value, Type
destinationType)
at System.ComponentModel.TypeConverter.ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.DateTimeConverter.ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, Object value, Type destinationType)
at Telerik.WinControls.UI.RadGridDateTimeConverter.ConvertTo(ITypeDescriptorContext
context, CultureInfo culture, Object value, Type destinationType)
at Telerik.WinControls.UI.RadDataConverter.FormatCore(Object value, Type targetType,
CultureInfo cultureInfo, IDataConversionInfoProvider dataColumn, Boolean checkForNullValue)
at Telerik.WinControls.UI.RadDataConverter.FormatNullValue(Object value, Type
targetType, CultureInfo cultureInfo, TypeConverter dataTypeConverter, IDataConversionInfoProvider
column, Object& result)
at Telerik.WinControls.UI.RadDataConverter.FormatCore(Object value, Type targetType,
CultureInfo cultureInfo, IDataConversionInfoProvider dataColumn, Boolean checkForNullValue)
at Telerik.WinControls.UI.RadDataConverter.Format(Object value, Type targetType,
Boolean coerceNullValue, IDataConversionInfoProvider converstionInfoProvider)
InnerException:
Thank you for writing.
I created a sample project and tried to reproduce the exception which you describe but to no avail. In my example the BestFitColumns method is called on a Click event of a button, I have also tried calling it just after binding the grid to the data source, in both cases the result is the same - an exception is not thrown. Please see my example below:
public
Form1()
{
InitializeComponent();
DataTable dt =
new
DataTable();
dt.Columns.Add(
"Name"
,
typeof
(
string
));
dt.Columns.Add(
"Age"
,
typeof
(
int
));
dt.Columns.Add(
"Date"
,
typeof
(
string
));
for
(
int
i = 0; i < 50; i++)
{
if
(i % 2 == 0)
{
dt.Rows.Add(
"Name "
+ i, 20 + i, DateTime.Now.AddDays(i).ToLongDateString());
}
else
{
dt.Rows.Add(
"Name "
+ i, 20 + i,
null
);
}
}
this
.radGridView1.DataSource = dt;
this
.radGridView1.Columns.Remove(
"Date"
);
GridViewDateTimeColumn dateTimeColumn =
new
GridViewDateTimeColumn(
"Date"
);
dateTimeColumn.FieldName =
"Date"
;
dateTimeColumn.FormatString =
"{0:D}"
;
this
.radGridView1.Columns.Add(dateTimeColumn);
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
this
.radGridView1.BestFitColumns(BestFitColumnMode.DisplayedCells);
}
Could you please share more details of your particular scenario? Feel free to modify my example so that it reproduces the exception. We would be happy to further investigate and quickly provide you with a working solution.
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hi Hristo,
If you specify the DataType property to typeof(DateTime) on the date column, you will get the error even when trying to filter column.
Cheers
Thank you for writing.
The sample project as per my old snippet is still running fine on my end. Can you please open up a support ticket and send us your project reproducing the exception?
Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik by Progress