Quick Visual Studio .NET Tips

Still getting used to Visual Studio .NET? Here are a handful of little-known Visual Studio tips sure to make your life easier...

Writing a Developer TODO: List

The Task window in VB.NET is a great way of keeping track of tasks that are related to your project. For example, if you have code issues or compile errors, VB.NET will automatically list them here.

You also can add your own comments to the Task list, with the TODO keyword. To use this feature, simply add a comment to your code that starts with the TODO keyword. It will automatically be added to your existing Task list. For example:

' TODO: Rewrite function so works with .DOC files

To view the Task list, select View > Other Windows > Task List from the menu, or press Ctrl+Alt+K. The Task list often filters its contents, so it displays only certain information. To view everything, right-click on your list and select All Tasks > All.

Top Tip: Fed up with the TODO keyword? Users of Visual Studio .NET 2003 (Everett) have automatic support for the "HACK" prefix, which works in the exact same way as TODO, yet attracts much more kudos. You can edit the Task list keywords yourself by editing the values in Tools > Options > Environment > Task List.

Click here for a larger image.

Figure: If only all TODO lists were this short...

Storing Often-Used Code in the Toolbox

There's an easy way to store often-used code and templates in VS .NET. Simply drag and drop your code straight onto one of the toolbox tabs, such as the General tab. When you need to use it again, simply drag and drop back into your code window. And, best of all, these snippets persist from project to project, saving even more development time.

Click here for a larger image.

Figure: Adding code to the toolbox

Organizing your Project with Folders

Overwhelmed with the number of files that now make up your application? Starting to lose track of which .VB files do what? Well, there's a simple method of keeping track. Use folders!

Right-click on your project in the Solution Explorer and select Add > New Folder. Then, simply drag-and-drop your existing code files into the new folders. For example, you may have one folder called "User Interface" to store your forms. Or a folder called "Database Code" to store your data access classes.

Don't worry: there's no extra configuration required; your entire project compiles as normal with no extra effort. It simply allows you to organize your project the way it should be.

A simple tip, but one that can turn chaos into control within minutes.

Figure: One of my company C# projects, really taking advantage of folders

Discovering Whether You're Running in the IDE

Previous versions of Visual Basic made it easy to figure out whether you were running your application through the IDE (Integrated Development Environment). It simply allowed you to check which "mode" your application was in. VB .NET, however, isn't quite as easy-going.

The most common method of figuring out whether the application is running in the .NET IDE is to check the System.Diagnostics.Debugger.IsAttached property to determine whether a debugger is attached to the currently executing code. If so, you can safely assume your code is running from within the IDE.

If you're designing your own controls, you might also run into the situation where your code is running in design modewhile you only want it to execute during 'full' runtime. In this situation, simply check the DesignMode property of your component (that is, from inside your control: Me.DesignMode). If it returns True, you're running in the IDEb—so cut your code short.

A simple solution to a common question, and definitely worth remembering.

# # #

About the Author

Karl Moore

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is the author of numerous technology books, including the new Ultimate VB .NET and ASP.NET Code Book (ISBN 1-59059-106-2), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at www.karlmoore.com.


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date