ShapeArray 的问题以及将其转换为 C#
我已将 VB6 应用程序转换为 VB.NET,因为最终我想将其转换为 C#。但我对继承 BaseControlArray 的 ShapeArray 有问题。这些是我的问题:
我在 VB .Net 解决方案中创建了一个 RectangleShapeArray 类。然后我转换为 C#。
但是,当调用 RectangleShapeArray.Load(1) 时,它表示矩形形状数组没有要克隆的现有形状,并且我应该在设计时向其中添加一个形状。
但我找不到在设计时向 RectangleShapeArray 添加控件的方法。 有没有办法在设计时向 RectangleShapeArray 添加控件?
I have converted a VB6 application to VB.NET, because eventually I want to convert it to C#. But I have problems in regard of ShapeArray that inherits BaseControlArray. These are my problems :
I create a RectangleShapeArray class in the VB .Net solution. And then I converted to C#.
But when calling RectangleShapeArray.Load(1), it says that the rectangle shape array doesn't have an existing Shape to clone, and that I should have add a Shape to it at design time.
But I can't find a way to add a control to the RectangleShapeArray at design time.
Is there a way to add a control to RectangleShapeArray at design time ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不。.NET Windows 窗体设计器不支持控件数组,当以前的 VB6 程序员第一次意识到这一点时,他们感到非常失望。
但如果您认真考虑一下,设计器中的控件数组无论如何都没有多大意义:它们几乎总是动态,并且根据运行时约束使用不同数量的控件。那么,在编译时设计它们就没有多大意义。
完全避免.NET 中的控制数组类,它们不再是必要的。如果您有可变数量的控件,请改用普通的控件列表/数组(由于 VB6 实现事件的方式,VB6 不支持此功能)。在表单设计器内,仅创建静态控件,而不创建控件数组。
No. Control arrays are not supported by the .NET Windows Forms designer, which is a huge let-down for former VB6 programmers when they realize it first.
But if you really think about it, control arrays in the designer don't make much sense anyway: They are almost always dynamic, and use different numbers of controls depending on runtime constraints. Designing them at compile-time, then, doesn't make much sense.
Avoid control array classes in .NET completely, they are no longer necessary. If you have variable numbers of controls, use normal lists/arrays of controls instead (VB6 didn't support this because of the way VB6 implemented events). Inside the forms designer, only create static controls, not arrays of controls.