Visual Studios 设计器实现中的表单继承
我正在将项目从 Visual Studio 2003 迁移到 2005,并且刚刚看到
事件 Click 是只读的,无法更改
在使用继承的表单时无法更改,无论基本表单控件上的修饰符如何都会使设计器中的所有来自基本表单的控件为只读(尽管在 2003 年,它并没有以这种方式工作)。
我发现这篇文章提到此功能已暂时“禁用” http://social. msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/c25cec28-67a5-4e30-bb2d-9f8dbd41eb3a
谁能确认是否再使用此功能?或者如何围绕它进行编程以便能够使用基本控制事件并且仍然有设计器?
这是我发现的一种方法,但当它用来为你做管道工作时非常痛苦。即使只是隐藏您现在手动执行的控件之一。
Public Class BFormChild
Friend Overrides Sub cmdApply_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdApply_Click(sender, e)
End Sub
Friend Overrides Sub cmdCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdCancel_Click(sender, e)
End Sub
Friend Overrides Sub cmdOk_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdOk_Click(sender, e)
End Sub
End Class
I'm in the process of moving a project from Visual Studio 2003 to 2005 and have just seen the
The event Click is read-only and cannot be changed
when using inherited forms regardless of the Modifier on the Base Forms Controls will make all the Controls from the Base Readonly in the designer (Though in 2003 it didn't work this way).
I found this post mentioning that this functionality has been temporarily" disabled
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/c25cec28-67a5-4e30-bb2d-9f8dbd41eb3a
Can anyone confirm whether this feature is used anymore? Or how to program around it to be able to use the Base Control Events and still have a designer?
This is one way I've found but quite painful when it used to do the plumbing for you. Even just hiding one of the controls you have manually do now.
Public Class BFormChild
Friend Overrides Sub cmdApply_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdApply_Click(sender, e)
End Sub
Friend Overrides Sub cmdCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdCancel_Click(sender, e)
End Sub
Friend Overrides Sub cmdOk_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MyBase.cmdOk_Click(sender, e)
End Sub
End Class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
生成事件的基类需要标准事件生成模式。这必须在代码中完成,设计者无法自动生成它。它永远不会。
Base classes that generate events require the standard event generation pattern. That must be done in code, the designer cannot auto-generate it. It never will.