Controls disappearing

huhhuhhuh

Active member
Joined
Feb 28, 2006
Messages
42
Programming Experience
Beginner
I opened my VB.NET project and all of a sudden, all of the controls on the form were gone. I tried running it and the form opens normally with all the controls and stuff showing up like they normally do after my login screen. The only difference is a whole bunch of errors cropping up stating so-and-so not declared. However, attempts to open the page in designer view resulted in a completely blank form appearing. Similarly, no controls appear for the form in the dropdown in codeview. I tried googling this problem but no solution has come up. Can someone please respond asap cuz this project is urgent and due next week. Thx.
 
I have heard of this problem before, am i right in saying that if you look in the windows forms designer generated bit all the code for the location and text etc are there but the actual private,friend withevents button1 as new system.windows.forms.button isn't there. If so this is usually due to repeated builds and rebuilds, adding/removing things from the windows toolbox again and again etc.

If you add the

Friend withevents....

bit back in it will work. But i recommend you back up this project as soon as possible.
 
Thanks, I just found a few articles describing a similar solution. However, when I look for the Windows form generated code segment, it's missing!

I don't know how this came about. I don't even remember going anywhere near the Windows generated code. And if the code is missing, how is it that all the controls and even database operations are showing up and working properly during runtime, with the exception that a host of 'non declared' errors are cropping up? Has the Windows generated code hidden itself somewhere?

I'm not great with programming and am still struggling with all the VS concepts and features. It has taken me over a month to get to this point and the project is due next week. I would appreciate any help regarding this matter. Thx.
 
This isn't something that visual studio has doen intentionally, for the want of a better word .. it's a bug. My advice would be to create a new form add the controls to as they were on the form that is playing up and add the code you have written. Then delete the malfunctioning form.

Just a further word of advice (and this will be difficult until you become for experienced with vb.net)

'Build it once, and build it right the first time'

Of course it's nearly impossible to do it right first time, but computers, no matter how advanced, are the same when it comes to writing over the same patch of memory again and again and again. Eventually subtle errors will creep in like the ones you are experiencing.
 
Thanks. However, what's puzzling is that all the items show up perfectly during runtime, and all the listboxes are properly populated with the appropriate content. Only thing is, the Windows generated code is missing in design view, and I find code initializing the new, blank form component which I did not write, did not declare, so forth. This 'new' piece of code seems to have replaced the Windows code.

I'm not exactly thrilled at the prospect of redesigning the entire form again, especially when the form happens to be the core of my project and filled with various tabpages and countless listboxes, textboxes, so forth. Guessing and rewriting the Windows code would be much faster than redrawing the entire form.

I'm curious now as to how the controls and form still show up normally during runtime. Perhaps I can draw a solution from that.
 
Just how many controls are we talking about here?. As i have heard of a known bug that occurs when too many controls are used in one form. Microsoft are aware of this problem but to date i don't know of any fixes.
 
Like 8 tabpages, each with at least 4 labels, 2 listboxes, assortment of textboxes/areas, buttons, so forth.

All the functions are intact. Everything shows up fine during runtime. Only, a whole bunch (like near a hundred) errors are cropping up saying so-and-so not declared. Yet, despite claiming that certain connections were not declared, all the listboxes were populated properly.

Codewise, as mentioned before, the Windows generated code seems to have disappeared, replaced only with initialization of blank form. This new code isn't even tagged as Windows generated code, it just appears at the end of the page no matter how many times I delete it.
 
Just a thought, does Option Strict cause effects such as this. It's the only notable thing I can think of. I have no idea what it does and haven't bothered to look it up. Prior to this problem, I had trouble getting some sample code to work so I added it based on the sample. The code still didn't work so I removed it along with the sample. The problem occurred during the next session which was today, prior to this post.
 
No, turning on option strict wouldn't cause this behaviour. Turning on option strict means that things like implcit conversions are not allowed. For example if i had dimensioned DR as a datarow and was trying to get the information at a column index...

VB.NET:
dim Str as string = dr.item(2)
With option strict off this would be permitted as the conversions would take place on the fly at compile time however with it on i would have to explicitly convert it to a string 'object' before it would compile..

VB.NET:
dim str as string = convert.tostring(dr.item(2))
 
I don't know what's going on anymore. I've been looking for possible solutions for the past few hours to no avail.

What I want to know right now is why the controls as well as the associated functions are showing up and working properly during runtime. Everything seems to work save for db operations involving connections not declared in the login form. That means despite error stating the connection hasn't been declared, as long as the db operation involves connection from first form, it's fine. Everything else is created and works as before too.

So why isn't it showing up in design view? If the problem is due to the disappearance of the Windows generated code, shouldn't this be reflected during runtime as well? Or does VS refer to something other file or reference during runtime? If so, this reference should have everything required to retrieve or reconstruct the Windows generated code.

Any help shedding light on this issue would be greatly appreciated.
 
bump. Here's the problem

1 : My Windows generated code is missing
2 : A new block of code specifying a new blank form as component appears
3 : At runtime, the blank form doesn't appear, my old form does. All controls turn up undeclared errors, but they somehow get displayed and function as normal.

Is there any way or any application that can restore/regenerate the Windows generated code?
How are the controls and form getting built normally during runtime? Can I derive new Windows generated code from this source?

I've spent an entire day on this and 'redrawn' my huge form to about 20percent and as accurately as I can based on the old form. However, the project is due next week and there are still a ton of things to be implemented prior to this problem occurring.

Any help is appreciated.
 
I've looked into this and all i can say is that particular file has somehow got corrupted. I'm sorry but i don't think this can be resolved short of a re-write. If it is compiling then it must be the IDE. So if you don't want to re-write it then just leave it alone and finish yuor project then hope it compiles a functioning release version. Not really a solution i know, but some things can't be fixed.
 
Okay, just noticed something funny. I finally decided to test out my 'new' redrawn form, or what little I have of it. I rename it to the 'corrupted' form. And then I run it, but it doesn't appear! Instead, the same old form appears with the same errors.

Then, I tried moving the old form to a new location. The solution explorer indicates the file is missing. I run it. Same thing happens. Old form appears with same errors.

I went ahead and deleted the entire form. Same scenario.

Can someone tell me where VS is getting the instructions to draw the controls? At this rate, drawing a new form won't do any good. I'd have to start a whole new project.
 
Okay, I may be on to something here. Apparently, I had initially declared my 'corrupted; form as a class. Therefore, I assume that anytime I run the project, the code will create a new instance of that class and direct me from my login page to this class or 'corrupted' form in initial state, not the new modified Windows codeless form.

When I try to create a new form using the name of the corrupted form, I also get a response saying the item already exists. Anyone with experience or knowledge regarding this please respond. Is it possible for me to create a new form and import the original class/form? I can't seem to locate it or add it using 'Add existing item' Thx.
 
Back
Top