使用 Infragistic 样式时在 ResumeLayout(false) 上引发 Load 事件
我在使用 Infragistics 样式时遇到问题,该问题与过早引发 Load 事件有关。
一些上下文:
- 我有一个由 UserControl 表示的视图
- 当我想显示此用户控件时,我创建一个新实例并将其添加到“主机”表单中,该表单具有一些与问题无关的额外行为。
如果我不使用样式,则在显示表单时会正常引发 Load 事件,这正是我所期望的,但如果我使用 StyleManager.Load
方法并加载样式,则在我的一个面板中执行 ResumeLayout(false)
时,会引发 UserControl 的 Load 事件,这发生在构造函数中的 InitializeComponents
方法中。
这是预期的行为吗?有人遇到过同样的问题吗?
编辑: 这似乎只发生在Office2007风格,如果我使用Office2010风格,一切正常,
谢谢
I'm having a problem when using Infragistics styles, the problem is related to the Load event being raised prematurely.
Some context:
- I have a View that is represented by a UserControl
- When I want to show this user control, I create a new instance and add it to a 'host' form that has some extra behaviour non relevant to the problem.
If I don't use styles, the Load event gets raised normally when the Form is shown, which is what I'm expecting, but if I use the StyleManager.Load
method and load a style then the Load event of the UserControl is raised when doing ResumeLayout(false)
in one of my panels, which happens in the InitializeComponents
method in the constructor.
Is this expected behavior? Has anyone experienced the same problem?
edit:
This seems to be only happening with the Office2007 style, if I use the Office2010 one everything works fine
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
非常典型的基础设施损失。当构造函数执行任何需要 Handle 属性有效的代码时,通常会发生这种情况。这会导致 CreateHandle 方法运行,进而触发 Load 事件。您没有发布堆栈跟踪,因此无法查看哪种代码导致发生这种情况。我毫不怀疑这是基础设施代码。获取他们的最新更新,如果您需要他们的支持,请发布到他们的支持论坛。并尝试将代码从 Load 事件处理程序移动到构造函数,只有当您的代码需要知道表单大小时才需要 Load。
Pretty typical Infragistics lossage. This can happen in general when any code is executed by the constructor that requires the Handle property to be valid. That causes the CreateHandle method to run, which in turn gets the Load event triggered. You didn't post a stack trace so there's no way to see what kind of code causes this to happen. I don't doubt it's Infragistics code. Get their latest updates, post to their support forum if you want their support. And try to move code from your Load event handler to the constructor, you only ever need Load if you have code that requires the form size to be known.