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.

Comments

  • 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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds