By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

Controls disappear from designer...

P: n/a
I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated
region.. I'm not really sure what happened to them, but this has
happened before where one or two will disappear.. They are still in the
code too.. And if I try to add a new control with the same name, it says
it exists... Any ideas?
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Aaron Smith" <th**********@smithcentral.net> schrieb:
I have a problem... Have a form, made some changes.. now all the controls
are gone. I didn't make any changes to the designer generated region.. I'm
not really sure what happened to them, but this has happened before where
one or two will disappear.. They are still in the code too.. And if I try
to add a new control with the same name, it says it exists... Any ideas?


Maybe the designer lost the 'Me.Controls.AddRange(...)' line that adds all
the controls to the form. Make a backup of the form and check if the
controls are added to the form's 'Controls' collection and add the line if
it is missing.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
Aaron -

There are a number of reasons this will happen, so I can't tell you why it
happened. Usually this happens because some code you wrote created an error
condition that would not allow the form design to complete.

I can tell you how to fix it without starting all over, however. In the
code for the form, check the mysterious "Windows Form Designer generated
code" region...

It normally looks something like this:

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(0, 0)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(568, 421)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form2"
Me.ResumeLayout(False)

End Sub

#End Region

What usually is missing is the line(s) in the InitializeComponent section
thats sets your control objects to new instances of the control:

"Me.TextBox1 = New System.Windows.Forms.TextBox"

OR the line(s) that add the control(s) to the form's control collection are
missing:

"Me.Controls.Add(Me.TextBox1)"

Just figure out what is missing, and type it in, and you should be good to go!

--Zorpie

"Aaron Smith" wrote:
I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated
region.. I'm not really sure what happened to them, but this has
happened before where one or two will disappear.. They are still in the
code too.. And if I try to add a new control with the same name, it says
it exists... Any ideas?
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #3

P: n/a
Herfried K. Wagner [MVP] wrote:
"Aaron Smith" <th**********@smithcentral.net> schrieb:
I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated
region.. I'm not really sure what happened to them, but this has
happened before where one or two will disappear.. They are still in
the code too.. And if I try to add a new control with the same name,
it says it exists... Any ideas?

Maybe the designer lost the 'Me.Controls.AddRange(...)' line that adds
all the controls to the form. Make a backup of the form and check if
the controls are added to the form's 'Controls' collection and add the
line if it is missing.


I think you are right.. And I think I know what happened... I had three
forms that were inheirited from another form and that form had a panel
on it.. I got rid of the panel and rebuilt the app by accident.... I bet
that did it... ugh. This sucks.

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

P: n/a
Herfried K. Wagner [MVP] wrote:
"Aaron Smith" <th**********@smithcentral.net> schrieb:
I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated
region.. I'm not really sure what happened to them, but this has
happened before where one or two will disappear.. They are still in
the code too.. And if I try to add a new control with the same name,
it says it exists... Any ideas?

Maybe the designer lost the 'Me.Controls.AddRange(...)' line that adds
all the controls to the form. Make a backup of the form and check if
the controls are added to the form's 'Controls' collection and add the
line if it is missing.


By the way,

THANK YOU! THANK YOU! THANK YOU! lol I was freaking out... I added one
line and now they are coming back... whew.

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #5

P: n/a
Yep, Herfried, clued me in to look around and I found it.. Let me tell
ya, I was freaking out there for a minute!

Zorpiedoman wrote:
Aaron -

There are a number of reasons this will happen, so I can't tell you why it
happened. Usually this happens because some code you wrote created an error
condition that would not allow the form design to complete.

I can tell you how to fix it without starting all over, however. In the
code for the form, check the mysterious "Windows Form Designer generated
code" region...

It normally looks something like this:

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(0, 0)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(568, 421)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form2"
Me.ResumeLayout(False)

End Sub

#End Region

What usually is missing is the line(s) in the InitializeComponent section
thats sets your control objects to new instances of the control:

"Me.TextBox1 = New System.Windows.Forms.TextBox"

OR the line(s) that add the control(s) to the form's control collection are
missing:

"Me.Controls.Add(Me.TextBox1)"

Just figure out what is missing, and type it in, and you should be good to go!

--Zorpie

"Aaron Smith" wrote:

I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated
region.. I'm not really sure what happened to them, but this has
happened before where one or two will disappear.. They are still in the
code too.. And if I try to add a new control with the same name, it says
it exists... Any ideas?
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #6

P: n/a
"Aaron Smith" <th**********@smithcentral.net> schrieb:
THANK YOU! THANK YOU! THANK YOU! lol I
was freaking out... I added one line and now they are
coming back... whew.


Glad to see that you were able to solve the problem :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7

P: n/a
On Thu, 02 Dec 2004 20:52:30 GMT, Aaron Smith wrote:
I have a problem... Have a form, made some changes.. now all the
controls are gone. I didn't make any changes to the designer generated


I see that the others have helped you. I just wanted to report another
cause that I discovered. It happened to me at least. I was working on a
project and my controls on my form started disappearing or displaying
incorrectly. It turned out that I had messed up the app.config and the xml
in that file was not properly formed. I'm not sure why that would affect
the designer, but it did and as soon as I fixed it, the form returned to
normal.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #8

P: n/a
Why does this happen? I get this happening quite frequently and other odd
events at design time. The IDE is SOOO flakey! I am using VS.NET 2003, I
hope these issues are fixed in the 2005 version!

Landley

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Aaron Smith" <th**********@smithcentral.net> schrieb:
THANK YOU! THANK YOU! THANK YOU! lol I
was freaking out... I added one line and now they are
coming back... whew.


Glad to see that you were able to solve the problem :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.