How to place code snippets within Visual Studio 2010 Toolbox window? - visual-studio

I've really enjoyed Anders Hejlsberg presentation at BUILD 2011 and it's not the first time that I notice someone having a collection of code snippets available within Visual Studio's Toolbox window, so given that all the searches I've performed so far pointed me to how to deal with IntelliSense snippets, I was wondering if anyone knows how to achieve this?

You just need to copy the code to the toolbox. A simple selection of the code, and a drag and drop to the toolbox just make it available. It will not be deleted until you delete it (at least that never happens to me by itself)..
This is what you need?

Related

Refactor menu missing from Visual Studio 2015

I am having trouble finding the right-click context menu in Visual Studio 2015. I know that nothing is wrong with my project or the file I am working. I can find the right-click context refactor menu in Visual Studio 2013. However, in Visual Studio 2015 there isn't a refactor context menu in the right-click context menu.
Where did it go? How do I get it back?
Your suggestion cannot include menu Edit → Refactor.
I have tried to reset my Visual Studio settings back to default using menu Tools → Import and Export Settings and that didn't bring the menu back either.
Some of the refactoring tools have been relocated or are at least accessible in a different manner than they were previously.
Using the extract method refactor as an example, you can still use this function; it is just not done the same as before:
Right click
Quick actions
Click extract Method
I think they've changed it to feel more "ReSharper"ey. All of the functionality should still be there however.
Here's more information on refactoring in Visual Studio 2015 - hopefully this helps! Refactoring (C#)
You no longer need to access the refactoring using the mouse right click.
It is recommended that you use the keyboard shortcut keys within Visual Studio.
For all possible shortcut keys, see Default Keyboard Shortcuts in Visual Studio, Refactor.
You might need to build the project to get it to work.
See Code Editing ASP.NET Web Forms in Visual Studio 2013 | Microsoft Docs. (If it is missing then the point is that I am using an example provided by Microsoft.). In Refactoring and Renaming see To extract a method in a C# page. When I follow the instructions I cannot find the feature to extract the code to a method. When I tried the Edit menu it said I did not have valid code. Then I built the project and the feature to extract the code was available and worked.
If you change the name of the object you are refactoring, the light bulb then appears to the left which asks if you wish to change the name of the object (i.e. refactor) or generate a new constructor for the new named object.
Ctrl + . is the shortcut key for extracting a method in Visual Studio 2015 and onward.
Ctrl+M, R does not work anymore in new versions.

How do I print the screen layout in Visual Studio 2012 (Windows Forms)

I have a complex form that I created in Visual Studio 2012; I want to print out that form exactly as it shows in the designer using Visual Studio 2012 (not while the program/form is running). Is this possible?
I know I can just do a screen shot, but I will need to be doing this quite often and would prefer a simple, direct way to do this.
I'm not sure if there's anything within visual studios that does exactly what you're suggesting.
I would definitely recommend snagit. We use it at work quite a bit when putting together internal documentation.
http://www.techsmith.com/snagit.html
You just click and drag and it saves everything in one location. You can also do a quick click on the title bar of the vs window and it will save a screenshot of everything within that window. It's a lot easier than constantly pressing the print button and then pasting it somewhere.
Or you could write your own program that does exactly what you need it to do.

Prevent Visual Studio to scroll to the end of file when pressing Ctrl A (select all)

It's basically in the title.
Whenever you "select all" in the Visual Studio code editor, the editor will scroll down to the bottom of the file. Is there a way to prevent this?
I'm using Visual Studio 2008 at the moment, but this applies to all versions.
No, you cannot change this behavior.
Microsoft has been aware of this since at least VS 2010, but either doesn't think it's a bug or doesn't think it's important enough to fix.
From their response to a 2010 bug report filed on the issue:
We unfortunately do not plan to change Ctrl+A's scrolling at this
time, so we're unfortunately resolving this issue as Won't Fix for VS
2010. However, it will remain in our database to be revisited for a future release of Visual Studio.
Source: Microsoft Connect
A quick Ctrl-Z-Ctrl-Y will get you back to where you were. If you tend to do a Ctrl-S Ctrl-A Ctrl-C a lot then just get used to this whole chain instead: Ctrl-SACZY. Or, create a macro: https://msdn.microsoft.com/en-us/library/a0003t62%28v=vs.90%29.aspx
I was struggling with this myself, but the "undo" suggestion gave me an idea and I feel kinda dumb for not thinking of it earlier. Visual Studio includes "Navigate Backwards" and "Navigate Forwards" buttons (CTRL-, and CTRL+, respectively). So after you finish selecting and copying, simple click the navigate backwards button or type CTRL- and voilà! you're back where you were.
I know it doesn't stop the scroll to begin with, but at least it puts your cursor back exactly where you left it!

Can i collapse all nodes in solution explorer in visual studio?

In visual studio, there seems to be no way to collapse all of a project's folders in solution explorer?
Does anyone know how this can be done?
Anyone? This has dogged me for years, i just wish there was a way without macros and addins, like they mention in this similar question Collapse all files at once in Solution Explorer window in Visual Studio
Microsoft released a pretty handy extension called CollapseSelection which does just that.
Yes you can.
Right click the project in solution explorer > Unload.
Then reload the project.
An age old problem fixed.
(Original answer by the OP, hidden inside the question. Now a true answer. Community Wiki to prevent unfair rep gain).

Visual Studio 2010 doubleclick behind #region to open it?

in Visual Studio 2008 it was possible to open a collapsed #region by simply double clicking somewhere behind (to the right) of the #region.
Now in VS 2010 you have to double click exactly the #region, double clicking behind it just selects the #region.
I've browsed the options but didn't find anything helpful and neither did google help.
Does anyone know of a way to switch back to the old behavior?
Thanks,
Florian
In Visual Studio 2010 the editor has been rewritten from scratch. It is quite likely that they just "forgot" to re-implement this functionality, thus causing a regression. If you feel strongly about bringing it back, I'd open a new bug at https://connect.microsoft.com/visualstudio/feedback
I don't think you can do it with the mouse anymore. Your best alternative is Ctrl+M, M (that toggles the current outline section).

Resources