1

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 ?

TAbdiukov
  • 1,185
  • 3
  • 12
  • 25
  • I don't remember these classes from VB6. Are they your own custom classes If so, could you show us some of the relevant code? – RBarryYoung Aug 25 '09 at 12:11
  • Just to clarify. ShapeArray is created by the Vb.NET upgrade wizard, when it sees a control array of Shape controls in the VB6? And you've created RectangleShapeArray class yourself? Do you have any working instances of RectangleShapeArray anywhere, in VB.NET or in C#? – MarkJ Aug 25 '09 at 12:52
  • Also: have you successfully completed the migration from Vb6 to VB.Net and then C#, and you are now extending your program? Or are you still trying to migrate from VB.net to C# and having trouble with that step? – MarkJ Aug 25 '09 at 12:56

1 Answers1

2

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 ?

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.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214