Click here to Skip to main content
15,904,926 members
Articles / Programming Languages / Visual Basic
Article

Regions Add-In for VS.NET 2003

Rate me:
Please Sign up or sign in to vote.
4.77/5 (53 votes)
11 Feb 20053 min read 361.7K   4.7K   127   133
Create an add-in for VS.NET 2003 to create regions.

Sample Image

Introduction

I find I spend a lot more time than I would like adding newly created functions to existing regions or new regions. So for myself and anyone else like me, I have developed this add-in.

Using the code

Two new commands are added to the context menu in the code window, when there is code selected.

Add To New Region will create a new Region, using the text supplied from a dialog, around the selected code.

Image 2

Add To Existing Region will show a dialog allowing you to select which region the code should be added to. You can also use this function to create a sub-region by ticking the checkbox.

Image 3

V2.0

I have added a couple of new features.

The Region Explorer

Image 4

This is a tool window that can be docked or floating, just like the Solutions Explorer and other VS tool windows.

  • Shows the position of regions in the opened document.
  • Can be used to 'jump' to a region that is not visible in the current document view.
  • Can be used to paste text from the clipboard to a region.
  • Can be used to add text to a region via drag'n'drop.

The Region Explorer is not available and will be empty, if the current active editor window is a Design View or any tool window type (e.g. Start Page, XML, etc...).

Use the Region Explorer command on the View menu to show, and the close button of the control to hide.

Setup Dialog

Also in v2 is a setup dialog to allow some flexibility in the way the add-in is configured. This setup can be accessed from the Tools menu or from the Image 5 button on the Region Explorer.

Image 6

Points of Interest

This version should work for C# and VB in VS.NET 2003.

It has not been tested under VS.NET 2002, but it will at least need the registry entries changing from:

HKEY_LOCAL_MACHINE\
 SOFTWARE\
   Microsoft\
     VisualStudio\
       7.1\
         AddIns\
           RegionsAddIn.Connect

to probably:

HKEY_LOCAL_MACHINE\
  SOFTWARE\
    Microsoft\
      VisualStudio\
        7.0\
          AddIns\
            RegionsAddIn.Connect,

although this is only supposition on my part.

Important

If the v1.x version was previously installed, it should be removed using the following process, before installing v2.0.

  • Close VS.NET.
  • Uninstall v1.x from Add/Remove Programs.
  • Open VS.NET (you may get a message declaring that VS.NET cannot load the add-in; this is fine, we want VS.NET to remove all its references to this add-in).
  • Load a project, and select some code. Right click, select 'Add To New Region'. (You may get a message declaring that VS.NET cannot load the add-in; this is fine, we want VS.NET to remove all its references to this add-in.) Now do the same for the 'Add To Existing Region' command.
  • Close VS.NET.
  • Install v2 of the add-in, and continue as normal.

History

  • 08/06/2004 - First release.
  • 15/06/2004 - v1.1. Updated code to fix bugs identified by 0siris, and Alex Kucherenko. Also, added check to stop any region that is spanned by the selection from being displayed in dialog.
  • 06/02/2005 - v2.0. Major rewrite to fix reported bugs and to add new features.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
JWT
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Upgrade: Regions Add-In for VS.NET 2005 Pin
MikeHamilton26-Sep-07 11:43
MikeHamilton26-Sep-07 11:43 
GeneralRe: Upgrade: Regions Add-In for VS.NET 2005 Pin
SteveMets9-Jan-08 9:07
professionalSteveMets9-Jan-08 9:07 
QuestionIs there a version for VS 2005? Pin
Hardy Wang26-Dec-05 8:24
Hardy Wang26-Dec-05 8:24 
AnswerRe: Is there a version for VS 2005? Pin
S Sansanwal8-Jan-06 14:39
S Sansanwal8-Jan-06 14:39 
GeneralRe: Is there a version for VS 2005? Pin
byangas3-Apr-06 10:13
byangas3-Apr-06 10:13 
QuestionHow do we rename/remove templates Pin
nelsonjm8-Dec-05 5:51
nelsonjm8-Dec-05 5:51 
AnswerRe: How do we rename/remove templates Pin
JWT10-Dec-05 1:30
JWT10-Dec-05 1:30 
QuestionProblems with shortcuts Pin
Ricardo Mendes2-Dec-05 5:14
Ricardo Mendes2-Dec-05 5:14 
Hi. I am using the regions add-in v2 and I've added a shortcut to prompt for the region name (add to new region). What happens is that when I restart the computer, the shortcut does not exist anymore.
I've used v1 also and it didn't do this. Is there anything I can do in order to Visual Studio not to lose the shortcut?

Thanks
AnswerRe: Problems with shortcuts Pin
JWT10-Dec-05 1:21
JWT10-Dec-05 1:21 
QuestionSupport for VS.NET 2005? Pin
M.Lansdaal5-Oct-05 15:28
M.Lansdaal5-Oct-05 15:28 
AnswerRe: Support for VS.NET 2005? Pin
dudedudedude7-Oct-05 18:14
dudedudedude7-Oct-05 18:14 
AnswerRe: Support for VS.NET 2005? Pin
JWT10-Oct-05 8:38
JWT10-Oct-05 8:38 
AnswerRe: Support for VS.NET 2005? Pin
M.Lansdaal13-Dec-05 7:54
M.Lansdaal13-Dec-05 7:54 
QuestionHow to add submenus? Pin
Erich Hohloch17-Aug-05 19:11
Erich Hohloch17-Aug-05 19:11 
AnswerRe: How to add submenus? Pin
JWT19-Aug-05 10:40
JWT19-Aug-05 10:40 
GeneralGreat addin! Pin
Dan Lipsy16-Aug-05 10:40
Dan Lipsy16-Aug-05 10:40 
GeneralRe: Great addin! Pin
JWT19-Aug-05 10:22
JWT19-Aug-05 10:22 
GeneralDocument is ReadOnly Pin
Tareq Muhammad17-Jul-05 11:00
Tareq Muhammad17-Jul-05 11:00 
GeneralRe: Document is ReadOnly Pin
JWT18-Jul-05 8:25
JWT18-Jul-05 8:25 
GeneralVisual Studio losts the shortcut Pin
Ricardo Mendes29-Jun-05 9:28
Ricardo Mendes29-Jun-05 9:28 
GeneralRe: Visual Studio losts the shortcut Pin
JWT30-Jun-05 8:11
JWT30-Jun-05 8:11 
GeneralVS 2002 Pin
andrija1129-Jun-05 2:02
andrija1129-Jun-05 2:02 
GeneralRe: VS 2002 Pin
JWT30-Jun-05 8:12
JWT30-Jun-05 8:12 
GeneralDon't Work! Pin
secnet4-Jun-05 3:15
secnet4-Jun-05 3:15 
GeneralRe: Don't Work! Pin
JWT4-Jun-05 7:11
JWT4-Jun-05 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.