Reputation: 300
I just added a new item to a toolstrip menu in my main form and all of a sudden all of my controls located on this form disappeared!
It's really strange as I didn't get any error or anything similar, I can also run the application normally but the controls are missing on my main form only.
I tried cleaning/rebuilding my solution and restarting Visual Studio 2012 but nothing seems to work.
This is what my main form looks like now:
Does anyone have any idea of what's going on? Thanks in advance!
Upvotes: 2
Views: 5327
Reputation: 1
I ended up with the same issue after accidentally double clicking a control. It created an event function in the form code and then created a call to that function somewhere else. In my case, I deleted the function from the form code, but the program was still trying to call that function. I merely had to delete the call.
Upvotes: 0
Reputation: 984
Since you did not posted any codes so let me assume the 'Disappeared Controls' are :
Friend WithEvents txtMDF As TextBox
Friend WithEvents txtLDF As TextBox
Friend WithEvents btnMDF As Button
Friend WithEvents btnLDF As Button
Friend WithEvents Label1 As Label
Friend WithEvents Label2 As Label
Where txtMDF, btnMDF, Label1, etc all are controls...
Step 1 - We have to go to the 'Designer Code'
Now from the Designer, Right-click and select 'View Code (F7)' then from the drop-down menu at top which contains the list of Controls select 'FormName' (The first item from the list e.g. above 'FormName Events') and then from the next drop-down menu select 'Initialize Component'
Step 2 - Add the following code under Private Sub InitializeComponent()
Me.Controls.AddRange(New Control() {txtMDF, txtLDF, btnMDF, btnLDF, Label1, Label2})
Step 3 - Voila! Done.
Now 'Save All' and return to the FromName Designer and you will get back all of your Controls as before.
Note: Please mark this answer as 'Answer' if it works because it will allow others to try the answer with little more confident! :D
You can follow Microsoft Support Page as well.
Upvotes: 4
Reputation: 11773
I opened a bug report for this after encountering other forums posts about the same issue.
Upvotes: 1