Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Just about everytime i create a new class i use the same 3 regions, Declarations, Properties, and Methods. I tried creating a macro to do this for me by letting it record my keystrokes. It worked ok but sometimes it screwed up and put stuff where it wasn't supposed to be. I know you can write macros using code... So how would i make a marco to do these regions for me using code?

Thanks

Brandon

i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted

You could modify the file at:

 

C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\Class\Templates\1033\Class.vb

 

which is the template for the New Class item, and change that. You can also add your own item templates, but it is a bit more work. There's probably some info in the MSDN about that.

  • *Experts*
Posted

You can also modify the template forms. There might be a way to add new templates, but I haven't looked.

 

Using C# as an example, I changed the following file:

C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddWinFormWiz\Templates\1033\NewWinForm.cs

 

Whenever I add a new form it uses this as the file. It does some fancy replacing so don't modify it too much. I removed most of the built in comments and added some regions, much like you're asking for. Plus a few more using statement (Imports in VB) that I use all the time.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

Forgot to mention, MAKE A COPY OF THAT FILE. You don't want to mess it up :)

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
WOW that is cool i just did it... so will this work if i say add a button to a form and copy the code? i'd like to hear some more details of how you guys used this to your advantage
i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted
For something like that you should look into using Form Inheritance. It's sort of limited, but can be useful for making things like dialog boxes and such.
Posted
yea i know about inheritance but then i can't edit the controls the way i want... if i had just one exit button on a form at load that i could play with (size and etc..) then i'd be happy
i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted
That sounds like it would be quite feasible. In fact, I may look into this myself and write an article about it. I haven't written anything for Tutors Corner in awhile.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...