Change .Text-property in designer without property-window - visual-studio

I am pretty sure in an earlier installation of visual studio I was able to hit F2 in the winforms designer to directly change the .Text property of the selected Winforms-Control (i.e. button).
This way I did not have to switch over to the property-window to search the .Text property. A nice time saving feature.
Unfortunately my active installation of VS 2017 doesnt support this or it is not activated in the settings, which I cant find an option for.
I'd appreciate if you could name me the option if you are aware of it.

F2 is typically tied to loading the Object Browser.
You should be able to select the control and start typing. When you select a control with the Property Window open, you should see that the Text property is automatically selected, but not in edit mode (the cursor is not in the input box). It jumps to edit as soon as you start typing.

Related

Where is the Sync with active document button in Visual Studio?

Where is the Sync with active document button in Visual Studio?
I know that I can press Alt + Shift + L and I will get the Sync with active document.
I also know that I can enable in the Options the feature to work every time I focus on another file.
But I can not find a button in the VS interface to do that. Is it even present? I would expect such a button be somewhere in the top of the interface of the VS. Somewhere near the comment/uncomment buttons (that is just my feeling that it is there, I have no proofs or reasons to think so).
I know this might sound silly, but I spent about a day trying to figure out where the button went in the latest VS2019 (Version 16.10.2) update.
After one complete day of using the keyboard shortcut instead, I realised that the Icon has changed to a different Icon.
Note: The Track Active Item in Solution Explorer checkbox should be unchecked to see this Icon, as posted by #Sandro Stadler.
Pretty simple.
If you check this option, the document and solution explorer will be automatically synchronized and the icon will be hidden.
Deselect to show the icon in the solution manager.
In VS 2019 it is in the Solution Explorer window:

How to give the focus (back) to my Visual Studio tool window

My project is a Visual Studio Extension which has a tool window. The tool window contains a grid control. A line in the grid corresponds to some part of a source code file, XAML file, ASP file or WinForms UI.
When you click in a cell in the grid, I want to find the corresponding think in your project, open it, select it, but afterwards I want the focus to be in the cell where you originally clicked, in the grid, in my tool window.
This used to work, but it is not working in my current version, in particular after selecting text in a XAML file.
To select text in the XAML file, I
start with the ProjectItem
open the corresponding window
activate it with window.Activate()
get the TextDocument object
manipulate the TextDocument.Selection to select text
After that I set the focus back to my tool window, by
casting the ToolWindowPane to IVsWindowFrame
calling the show method IVsWindowFrame.Show()
possibly setting the focus to a specific control in my tool window (but that is not really relevant)
I have made (at least) three significant changes:
I am using Visual Studio 2019
I am using async and await at a lot of places (but still running on the main thread)
My top level control is now a WPF control. Formerly it was WinForms
Maybe Visual Studio 2019 is doing something asynchronous in the XAML window, which was previously synchronous. This might mean that I set the focus back to my tool window, but lose it again immediately.
Is there a better way to force the focus back to my tool window?
Alternatively, is there some event I should wait for, before calling IVsWindowFrame.Show()?

Single layout for 'edit' and 'debug' in Visual Studio

In Visual Studio 2008, 'Start Debugging' switches Visual Studio to a different layout. How can I force Visual Studio to use a single layout at all times?
I could attempt to lay out my windows in both normal and 'Debug' modes as similarly as possible. However, i) Visual Studio will still do a visible redraw, and ii) I have to keep the layouts in sync manually.
Update: It seems the correct terms are 'Design View' and 'Debugging View'. According to Window Layouts: The Four Modes 'There is no way to tell Visual Studio to use one state for all modes at this time.' Is this really true?
As others have pointed out, you can't use one settings group to control both design and debug views. Visual Studio doesn't make it easy to get the most out of window placement settings, but the approach I use to manage layouts might help.
Instead of frequently adjusting window placements by hand, try to think of a fixed number of different views you want to work with. Eclipse has perspectives, window layouts you can switch between. Think of Visual Studio this way. For example, I use two layouts in Visual Studio: one to take advantage of two monitors when I'm sitting at my physical workstation, another for one monitor when I'm working remotely. If you can constrain yourself to using a group of layouts that makes sense for you without manually adjusting windows, you can make design and debug window placements the same for each layout.
However, switching between layouts is painful with Visual Studio out of the box. You have to go to Tools->Import and Export Settings and select the layout manually. It takes more than five mouse clicks and sometimes 15 seconds to switch layouts this way on my workstation. We can do much better!
Save the window positions you want for each layout to settings files
Make a macro to load each settings file
Bind the macros to keyboard shortcuts or toolbar buttons
Save window positions to a settings file
Arrange windows the way you want them for a specific layout. Visual Studio saves the location for nearly every window (e.g. Solution Explorer, Output, Find and Replace), so be thorough. Visual Studio saves design and debug layouts in a single file so arrange windows in both views.
Go to Tools->Import and Export Settings. Choose Export selected environment settings and click Next.
The next dialog prompts you to select the settings to export. Uncheck all settings except General Settings/Window Layouts so only window placements are saved, like in these screen shots (I can't expand the window so here are two shots of the same dialog):
Enter a name for this settings file and save it. Repeat until you have a settings file for each layout. There is no limit to how many settings files you may have.
Make a macro to load each settings file
Go to Tools->Macros->Macro Explorer to show your macros. There should already be a macro project named MyMacros. Create an empty macro project if none are visible. Double click any module in any of these projects to open up the macro editor.
Enter this into the editor. You want one main sub that takes a path to a settings file and loads the file, and one sub for each individual file that calls the main sub. If you save your settings files to the same folder you can have the per-file subs pass just the file name instead of the whole path.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Private RootFolder As String = "C:\Path\To\Folder\With\Settings\Files\"
Private Sub ImportSettingsFile(ByVal FileName As String)
FileName = IO.Path.Combine(RootFolder, FileName & ".vssettings")
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:""" & FileName & """")
End Sub
'Corresponds to file layoutA.settings
Public Sub ImportLayoutA()
ImportSettingsFile("layoutA")
End Sub
'Corresponds to file layoutB.settings
Public Sub ImportLayoutB()
ImportSettingsFile("layoutB")
End Sub
'Repeat for each settings file
End Module
Close the macro editor and go back to Visual Studio. You're done! Running any of these macros will load the settings files automatically. You can double click any of the subs in Macro Explorer to run them. If you display Macro Explorer at all times this might be sufficient, but if you don't or would rather not have to click the macros to run them we can do even better ...
Bind the macros to keyboard shortcuts or toolbar buttons
Go to Tools->Options->Environment->Keyboard. This window allows you to change any keyboard bindings. Type "Macro" without quotes into the Show commands containing text box. This will show the macros you created. Select any macro, click in the text box titled Press shortcut keys, and enter the keyboard shortcut you want to use to run the macro. Hit Assign, then OK. You can now use this keyboard command to load the settings file.
Alternately, you can use a toolbar button instead of or in addition to a keyboard binding. Go to Tools->Customize. Select the Commands tab, select Toolbar, and select the toolbar you want to add the button to (Standard is the main toolbar). Click Add Command, select the Macros category, select the macro you want to add a button for, and click OK. You will have a new button on the toolbar that loads the window layout from that macro.
Keep in mind that keyboard shortcuts and toolbar buttons are themselves settings. If you import a settings file that overwrites either of them you will have to redo this last step. The window placement settings files won't overwrite these values because you only exported window locations. It's a good idea to periodically export and back up all settings, not just window settings, in case something like this happens and you want to recover non-window settings.
No, this is not possible. The website you found is indeed accurate:
There are four different window layout modes in Visual Studio:
Design View - this is the one you see when you start up Visual Studio. It's what most people refer to as the "normal" view.
Debugging View - this is the view that you get when you enter Debug Mode like when you are stepping through your code
Full Screen - the view you get when you go to View -> Full Screen (Shift + Alt + Enter).
File View - the lesser known view you can get when you open up a file in DevEnv.eve
The thing to remember here is that, both, your tool windows and your command bar customizations are saved separately for each state. There is no way to tell Visual Studio to use one state for all modes at this time. Additionally, when you shut down Visual Studio in any state, all four states are saved.
It's very strange that you would want to use the same window layout for all four modes. The same windows that are useful at design time are hardly ever useful during debugging, and vice versa.
For example, in Debugging View, I hide the Toolbox, Document Outline, and Property Manager windows. Then, I add the immensely useful Call Stack, Autos, Locals, Processes, Modules, and Breakpoints windows. None of the latter panes would be remotely useful to me in design mode, so I don't want them taking up screen space. But they're invaluable in debug mode, so I want them to show up. I also resize windows in the two different modes, based on their relative importance (such as the Properties window).
If you really still think that the two views should have the same window layout, the best you can do is rearrange the windows manually to achieve the same layout in both modes. I also recommend exporting your Window Layout settings (Tools -> Import and Export Settings) so that you have a fresh copy to revert back to in the case of disaster. I keep settings files containing my preferred window layout settings for single monitor (laptop), dual monitor, and triple monitor configurations.
I think your question was, "How do I use the same settings for both modes?" Am I right? Although #Chris gave an excellent thesis on how to stuff automagically, I wanted to point out, for anyone else that finds this question that there is an easy way to acheive same window settings for both design and debug modes.
Export your settings:
Choose General Settings/Window Layouts (in VS 2013) and save the file.
Open the file in an XML editor (or whatever... it's an XML file)
Find /UserSettings/Category/Design/WindowProfile and copy the entire node.
-- This assumes your Design view is the one you want to use for both modes.
Find /UserSettings/Category/Debug/WindowProfile and replace it with the one you copied from Design.
Save and re-import.
I have one of these settings files for home, remote, and office.
Many people try to turn off this feature because of strange behaviors (glitches) of VS windows on multi-monitor configurations.
In such cases there is another option that can help:
Turn off Environment->General->"Optimize rendering for screens with different pixels densities"
https://developercommunity.visualstudio.com/content/problem/830128/windows-layout-not-restoring-properly-in-multi-mon.html

Customizing toolbar items in VS2010

Has the menu & toolbar customization functionality in VS2010 been reduced?
I can't seem to be able to select an icon for an added command, nor set it to be icon-only. Previous versions of Visual Studio supported this functionality and even allowed the creation/editing of custom icons.
Is this something that has suffered as a result of the move to the WPF-authored UI or am I missing something?
Seems like this functionality was cut from Visual Studio 2010. This post has some info in the comments: Customizing Visual Studio 2010
Specifically - "Unfortunately assigning or editing icons to commands through Customize dialog is not possible in VS2010. It is one of the features got cut for lack of time. This is however something we'll consider adding back in next version."
The reply also has a longer explanation of a workaround.
As noted in the link mentioned in the answer from #Gordon Mackie JoanMiro, the REASON for the reduced functionality is that the VS Shell team migrated the entire UI (shell and command system) from Win32 to one based solely on WPF. This was a gargantuan task, I would imagine. However, a couple workarounds are now available:
You can export previously saved settings from VS 2008 and import them into VS 2010. That includes command bar customizations (as noted by #Don)
A more recent blog-post contains detailed instructions for using a new extension to VS2010 (available on Visual Studio Gallery) that allows users to change the images on the command UI. (Note that the old drag&drop customization interface is still not supported in this new extension.)
If you have custom icons, any attempt to make ANY changes to the tool bar will result in the custom icons disappearing and being replaced by text when you restart VS2010.
The only way I found to get my custom icons without text into VS2010 is to open VS2008, set up all of the tool bars the way I want, including custom icons, then export the settings (Tools| Import and Export Settings). Then open VS2010 and import those settings. Tedious, I know, but it allows me to have a down arrow icon that searches for the next instance of the word my cursor is on.
I have been trying to customize VS2010 toolbars/keyboard and what took a few minutes in previous versions takes hours now. The new system looks real pretty but is useless in practice. Apart from the fact you just can't do (like change the appearance of buttons as mentioned above) the things you can do are extremely time-consuming and annoying.
Why is it every new version of VS loses something really useful? Other examples:
VC++5 introduced a new HTML help system. Pressing F1 on a function name used to immediately show help for that function. After VC++5 getting context help became annoyingly much slower, and is still very slow (and inaccurate).
VS.Net (aka VS2002 or VC++7) had a useless bookmark system compared to VC++6. VS2010 bookmarks are better but not perfect.
VS.Net removed the search state buttons "whole word", "case sensitive" etc. These were possibly the most useful buttons ever as they quickly allowed you to see why a search may have failed.
I found a great extension: CommandingImage
It does not have an icon editor, but you can create your images as 16x16 png format (for transparency) and import it (I recommend Paint.Net)
Dave, here's how to add toolbar buttons:
1) in the IDE, find the down arrow looking thing on the far right of a toolbar and click on Add Remove Buttons, Customize
2) in the Customize window select the Menu Bar radio button then select the appropriate menu bar that you want to add a button to
3) click the "Add Command..." button
4) select the appropriate Category and Command button that you want to add, then click OK.
The command button you selected will be added to the menu bar you selected. You can move the button up or down.
I think this is what you are looking for.
Good luck!

Visual Studio UI Improvement OCD Mode

I am wondering if anyone knows how to pull this off. Here goes.
I have a multi monitor setup, and I maximize Visual Studio to both windows. I create a new vertical document tab control, so that I have one document tab control in each physical screen. This is fine.
Now, I want to be able to make them work as if they were connected. I want to have the designer on one side, and the code related to the displayed designer on the other window.
I'd like it to have the following functionality:
If a item is double clicked on the solution explorer, open designer/code in both tabs.
When a document is selected in either pane, open appropriate file in the other pane.
Make the designer view refresh on edit, or periodically.
Any ideas on how I could pull this off?
Try to check (wait) for VS 2010 (beta now). There should be multi monitor support.

Resources