المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : VB6 to C# conversion SetIndex issue



C# Programming
09-18-2009, 04:51 AM
I was wondering if anyone has run into this problem and gotten around it in any way. Currently I am performing a front end conversion from a VB6 GUI to C#. It is quite a big change and therefore we are performing this in stages. Now in this process we currently are using "Microsoft.VisualBasic.Compatibility.VB6" array objects at times eg.RadioButtonArray, CheckBoxArray, etc.

Now when using these, there is a "SetIndex" method that is used throughout the existing code and it seems that the designer does not like the idea of this method being called when EndInit has been called already. It essentially renders the designer useless and we get an error in the designer. What we currently do is in the "InitializeComponent" method we call only "BeginInit" on the various arrays, and then in the form constructor after "InitializeComponent" is called we have another method we created called "InitializeComponentArrays" which we call all methods needing to call "SetIndex" and then we call their "EndInit" methods. This allows designer to load everything fine until we make any adjustments to the designer. When this happens, the windows generated code inserts all the "EndInit" methods into the "InitializeComponent" method which causes the designer to crash, and I then need to go in and delete the lines that it has entered. It is quite annoying and I felt it was time to reach out and see if anyone else has any better resolutions.

Thanks everyone!
Dan