I upgraded a VB.Net VS2003 Windows Forms project to VS2005.
I have now VERY frequent problems with the designer!!
Some controls are "destroyed" in the designer.
They disappear from the declaration list (Friend WithEvents ....)
and turn up twice in the InitializeComponent procedure:
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim grdOldLanguages As System.Windows.Forms.DataGridView
Dim grdNewLanguages As System.Windows.Forms.DataGridView
.....
grdOldLanguages = New System.Windows.Forms.DataGridView
grdNewLanguages = New System.Windows.Forms.DataGridView
.....
CType(grdOldLanguages,
System.ComponentModel.ISupportInitialize).EndInit()
CType(grdNewLanguages,
System.ComponentModel.ISupportInitialize).EndInit()
I try to correct it in the Windows Forms section which works temporarily,
but the same problem will turn up the next time I do a change in my form.
I tried to create a new form in VS2005 which means I will have a dedicated
Designer file created. I move all controls and code to their proper places,
but I have still the same problem!!!!
So far my problem seems to be mainly related to the DataGridView controls.
Workarounds, Service Packs, .....?
Hi jaklithn,
Thanks for your post.
Regarding this issue, if you create a new project in VS2005, and use
DataGridView the same way as your original project, can the problem be
reproduced out? Have you tried to upgrade your project in some other
machine? Does the problem still exist?
I look forward to hearing from you. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jakob Lithner - 06 Feb 2006 13:01 GMT
My original machine has Win2000 with VS2003 and VS2005.
I have now tried similar actions on new projects on other machine with WinXP
and VS2005 and had almost identical problem. The problem usually appears when
I specify a name on my control. Comboboxes and DataGridViews has often been
the cause for me.
If I stick to the original name that the designer suggests, I have so far
not had the problem. But as you understand I am not really happy about using
meaningless default names ....
Your answer implies that the problem should be very limited to my particular
environment and project, but I doubt it is. The problem is far to frequent
and spread to different projects and machines. There must be someone else
that recognizes the same problem ....
> Hi jaklithn,
>
[quoted text clipped - 12 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 08 Feb 2006 06:54 GMT
Hi Steve,
Thanks for your feedback.
It seems that your problem is reproducible in new VS2005 project. And then,
can you provide some details steps to help us reproduce the problem on our
side for better understanding? Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jakob Lithner - 04 May 2006 16:46 GMT
I think I finally found it !!!!!
I have had exactly the same problem for months: Every time I modified some
particular forms, the designer went crazy and destroyed the xxx.Designer.vb
code. It was always the same problem:
a) One specific control was deleted from the Friend With Events declaration
b) A new row was inserted in the InitializeComponent section with a
declaration AND instantiation of the same control.
Result:
Missing With Events declaration
Double Instantiation
Designer complained on missing control declaration
The only solution was to manually correct the designer code and then QUICKLY
save and check in the file :)
Today I meditated on the problem: There was nothing wrong with the code
either in the forms file or the designer file. I checked it hundreds of times
.... So the remaining option was of course the resource file!
Alas! For all the problematic forms I found a similar setting defined in the
resource file: formName.GenerateMember. It was Typed as a System.Boolean and
everywhere set to False.
When I deleted the row all my problems disappeared, the designer is happy
again and never loses sync of the code!
One question remains: What action of mine triggered the designer environment
to sidestep the designer code generation?
I read the MSDN section on GenerateMember property but didn't really get the
connection to my experienced situation. But at least I have a simple action
that seems to solve my problem!
"Jeffrey Tan[MSFT]" - 05 May 2006 06:44 GMT
Hi jaklithn,
I am glad you finally resolves your problem.
Actually, I do not understand why deleting a control will generate such
problem in your project. I have never seen such problem.
Normally, the GenerateMember property specifies when the Windows Forms
Designer generates a member variable for a component. The link below gives
us an example of the GenerateMember property effect:
"How to: Use the Modifiers and GenerateMember Properties"
http://msdn2.microsoft.com/en-us/library/ms233630.aspx
I think because you set GenerateMember property to false, the designer will
not generate a member variable for the control, whenever you deleted the
control, there is no extra member variable left in the code file. Because
as you said, the problem is caused by duplicated member variable, set
GenerateMember property to false will prevent the problem. However, I am
not sure about the root cause.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.