Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What happened? My controls just disappeared! 1

Status
Not open for further replies.

ookete

Programmer
Joined
Oct 5, 2004
Messages
180
Location
US
On a form, I had about 10 inerited text boxes (MyTextBox) named "txtReject0" - "txtReject9". I run my project and I am getting errors, so I go back to the form designer and notice that all the text boxes are missing! I have no idea what I did. I know I didn't delete them, so I try to make new ones, but I can't name them txtReject0, etc because it says those components already exist and must have a unique name.

I check the "Windows Form Designer generated code" and I see that they still exist as:
Code:
Friend WithEvents txtReject0 As MyControls.MyTextBox
But they aren't initialized nor do they have any settings set.

Anyone know what happened? Thanks!
 
make sure they are in the
Code:
Me.Controls.AddRange(....)

line.
I've run into this a few times accidentally. I never figured out exactly what it was that caused it, but I think most of the time I just gave up and recreated the form.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
I've found that this problem occurs with User Controls that you don't compile separately into a .dll, in other words, the controls are part of the project.

Other that editing the Windows Forms region, then, as Rick says, the easiest method is to recreate the form.

However, since this has happened to me too many times, I now always treat my User Controls as completely separate projects and compile them to .dlls and then reference them in the normal way. This can be a pain, if you are still developing the control, but I think less of one than losing the controls as you describe.
 
Thank you for the advice. I am glad to know that I wasn't going crazy.
 
When it first happened to me I thought I was going crazy.[smile] It took ages trying to track down what was going wrong and I would spend hours editing the Windows Forms section. In the end, though, I just gave it up as a bad job and produced separate .dll libraries for my controls.

Glad to have been of some help, but, hopefully, VB 2005 will make the process easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top