|
-
Dec 15th, 2006, 06:22 AM
#1
Thread Starter
Fanatic Member
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?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Dec 15th, 2006, 07:30 AM
#2
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.
-
Dec 15th, 2006, 08:41 AM
#3
Thread Starter
Fanatic Member
Re: Can't Add Windows Forms anymore
Oh right...
Why has it suddenly changed?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Dec 15th, 2006, 09:33 AM
#4
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
-
Dec 15th, 2006, 10:57 AM
#5
Fanatic Member
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!
Warren Ayen
Senior C# Developer
DLS Software Studios ( http://www.dlssoftwarestudios.com/)
I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
Hey! If you like my post, or I solve your issue, please Rate Me!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|