Can't Add Windows Forms anymore
I am working on a VB.NET (2005) project which I have already several windows forms working fine.
However, whenever I now try to add additional forms, they get added but I get no New() event to handle (usually wrapped up in the "Windows Form Designer Generated Code" region). Indeed, the whole region is missing (along with the code that goes therein). The funny thing is that the form still opens and runs normally. Is it hiding this code somewhere?
Another thing it's not doing anymore is putting this line after the class heading:
VB Code:
Inherits System.Windows.Forms.Form
Even when I put this in manually, it doesn't bring back by "Windows Form Designer Generated Code" region.
What's going on? :ehh:
Re: Can't Add Windows Forms anymore
Click the icon in your Solution Explorer to "Show All Files". You should now be able to expand your form and see other files associated with it. The Windows Generated stuff is on the Form1.Designer.vb file.
Re: Can't Add Windows Forms anymore
Oh right...
Why has it suddenly changed?
Re: Can't Add Windows Forms anymore
Just seperated it out into its own parts. Pure user code in the form.vb file and then auto generated code in the form.designer.vb file. Most people never mess with the auto stuff anyway, so it prevents people that don't know what they are doing from messing up the form. Might not be the actual reason, but one that sounds good to me hehe
Re: Can't Add Windows Forms anymore
VB 2005 introduced "Partial" classes, a method at which you can split code up for the same class into more than one file (one file is the master, and would be Public Class classname, and the others are Public Partial Class classname, or the "child" parts.).
The idea behind it is to separate code logically yet have it all run in the same class. At the same time, this also keeps...less saavy users from deleting important code from their project. You can duplicate that yourself if you want to keep some code hidden from other developers - add the important code to the partial class and hide it. I'm sure that's not the only, or best explained reason, of course. :) It's just what I've gleaned from reading about it...
When you import a form from VB 2003, you can actually replicate this. Show all files, then go to the form in the project view and add a new file (new file, not new form), and name it formname.Designer.vb and then copy that generated code into it. Change it from Public Class to Public Partial Class and you're all set to go!