How to Place your reusable code into Toolbox in Visual Studio?

This is very important and small tips. Sometimes we have a small piece of code which can be used in different applications. What we do? We can create a common library and use that library in the different application. But there will be cases where we can not use this approach due to restrictions on naming conversion or namespace naming conversions or due to some other reason. So what we should do now.

Visual Studio having a great feature, that you can place your code snippet inside the toolbox. For that you need to just select the code snippet and drag the selected snippet on to the general Tab.


You can rename the selected snippet, by just right clicking on snippet and click on Rename.


Now, you can use it anywhere in your application or in any VS Application by just drag and drop of the selected snippet.

How to Place your reusable code into Toolbox in Visual Studio?

Being More Productive With Code Snippets

Code snippets have been around for a long time and is one of the easiest ways for the developer productivity.  We do use many of them frequently as they are very commonly in used, however there are a few which are really useful but many of us does not know about them.

For an instance,  a very useful time saver  code snippet is  “prop”  which is use for “Automatically implemented property” . In this case, if we type prop and then press TAB key twice, an automatic property will be added with default type of int . ( Refer the image below)


What if, if you want a property with declarative backing field ( Generally we defined them using a private variable and public exposed property  with same type)?  In this case rather typing the complete stuff, you can use propfullwhich gives you a private backing variable and then a public GET and SET with the link of just declared private variable.


You can change the type and variables name by just moving around the code block  using Tab Key press.

This will save a good amount of time compared to manual process.

Going forward, you can explore this kind of hidden snippet of  Visual Studio  just by navigating to “Code Snippets Manager” from “Tools –> Code Snippets Manager”. The following dialog window will help you to navigate through all the available snippet and the uses.


Being More Productive With Code Snippets

Ways to get more productive in Visual Studio

1. Find active document in Solution Explorer

Using menu options like “Go to definition” is great. But sometimes you’re taken to a document and you have no idea where the document belongs, especially if you have plenty of projects. By clicking on the Sync with Active Document button (see picture below), Solution Explorer will navigate to the location where the current document exists and mark it.


Continue reading “Ways to get more productive in Visual Studio”

Ways to get more productive in Visual Studio