简体   繁体   English

在 C# 中将 Crystal 报表添加到 tabcontrol 时出现问题

[英]Problem when adding Crystal report to tabcontrol in C#

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.我们正在动态配置 Crystal 报表,当我们在单独的 window 中显示它或将报表动态添加到 C# WPF StackPanel 时,一切正常。

But when we try to add them as TabItems to a TabControl we get an exception from PresentationFramework saying:但是当我们尝试将它们作为 TabItems 添加到 TabControl 时,我们会从 PresentationFramework 中得到一个异常,说:

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." e.Message = "指定的索引超出范围或索引处的子级为 null。如果 VisualChildrenCount 返回零,表示该 Visual 没有子级,则不要调用此方法。\r\n参数名称:索引\r\n实际值为 0 。”

How do I avoid this crash so that we can have crystal report in our TabControl?如何避免这种崩溃,以便我们可以在 TabControl 中获得水晶报表?

I've had the same problem when trying to put ComponentArt and Telerik controls inside of a TabControl in Silverlight.我在尝试将 ComponentArt 和 Telerik 控件放入 Silverlight 中的 TabControl 时遇到了同样的问题。 I had to make sure that I didn't try to load any of the components with data unless the tab that was containing those controls was the active one.我必须确保我没有尝试使用数据加载任何组件,除非包含这些控件的选项卡是活动的。

I ended up moving the initialization from the silverlight page's load event over to some logic in the Tab Controls SelectionChanged event I believe.我最终将初始化从 silverlight 页面的加载事件转移到我相信的 Tab Controls SelectionChanged 事件中的一些逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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