Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem when adding Crystal report to tabcontrol in C#

Hi!

We are dynamically configuring a Crystal report and when we show it in a separate window or dynamically adding reports to a C# WPF StackPanel everything is working as it should.

But when we try to add them as TabItems to a TabControl we get an exception from PresentationFramework saying:

e.Message = "Specified index is out of range or child at index is null. Do not call this method if VisualChildrenCount returns zero, indicating that the Visual has no children.\r\nParameter name: index\r\nActual value was 0."

How do I avoid this crash so that we can have crystal report in our TabControl?

Edited by: slemiz on May 25, 2011 10:55 AM

Edit: Stacktrace:
   at System.Windows.FrameworkElement.GetVisualChild(Int32 index)
   at System.Windows.Media.Visual.InternalGet2DOr3DVisualChild(Int32 index)
   at System.Windows.Media.VisualTreeHelper.GetChild(DependencyObject reference, Int32 childIndex)
   at SAPBusinessObjects.WPF.Viewer.ReportAlbum.ShowTabHeader(Boolean isShow)
   at SAPBusinessObjects.WPF.Viewer.ReportAlbum.ItemsChangedEventHandler(Object sender, ItemsChangedEventArgs e)
   at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index)
   at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
   at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)
   at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )
   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)

Edited by: slemiz on May 25, 2011 11:53 AM

Former Member
Not what you were looking for? View more on this topic or Ask a question