Um... My controls have disappeared?!

Reapz

Regular
Joined
Dec 15, 2002
Messages
74
I started a VB.NET project a while ago and had got quite far into it. I've recently reinstalled my system and yesterday I got around to reinstalling VS.NET. The project was saved into My Documents as per default which is located on a backup drive.

When I opened the project and opened up the 2 main forms I found that all the code was intact, one of the forms was intact but the controls on the other form have disappeared. I'm sure I have installed and referenced all ActiveX controls that I was using before.

I hope one of you guys has a solution because the form is quite complex and it will take bloody ages to replace all the controls.

Thanks in advance...
 
Oh and incidentally, there are no error messages or any indication of what the problem is and also I have tried to replace a couple of the controls and it won't let me because they already exist. I just can't see them!!!
 
Last edited:
Look at the form that works.

Look ar the generated code.

There you'll have:

Declaration of the controls
Instantiation (New() ...) of the controls
Initial setting of controls' properties (Name. Location etc....)
Adding of controls to containers (pnlMainPanel.AddRange ....)


Now look at the form where the controls have disappeared and try to figure out what is missing.

My two guesses are ...
a) either negative values in the "location property"
or
b) they are no longer added to their respective containers.



Things aren't that difficult.
 
This has been covered a few times - maybe we should add it to a FAQ (when we get one).

Check out your InitializeComponent function. Look at the VERY bottom where it sets properties for the form. It's probably missing the line:
this.Controls.AddRange(...)

If it is, it's probably missing a bunch of other lines as well. Sometimes .NET (maybe with SourceSafe, maybe not) just deletes those lines. I've seen it happen on a number of machines but never reproducable. Check source safe if you have it, otherwise you'll have to manually add the controls back to the form's collection.

-Ner
 
Yea you're right it does appear to be missing that line. I'll see what I can do with it cheers.
 
Back
Top