How do I create a shortcut to a menu in Windows Forms?
I think about something like in Visual Studio and Firefox, where I press Alt and mainly menu item's shortcut letters have been underlined.
How do I do this?
Use the ampersand (&) in front of the letter you want to use as a shortcut, like &File, in the text of the menu.
Also, if you're using Visual Studio, you should see the property for Shortcut Keys in the properties window as part of the designer. This will give you more options (like Shift and/or Ctrl, etc.).
Related
I have a Visual Studio Extension (vsix) with a quick info tooltip (IAsyncQuickInfoSource) that show a textbox (WPF). When you hover the mouse over a keyword it will show some useful info. The content of the textbox is selectable.
I like to copy the content of the textbox with Ctrl+C. However, instead of copying the content of the textbox into clipboard, text from the textbuffer where the quick info tooltip originated is copied.
The textbox is focusable. This minimal example project shows the undesired behavious.
Question: how to copy text of the textbox in my tooltip to clipboard.
To copy text to the clipboard you can use SetContent() method of Clipboard static class.
The issue of the shortcut is a bit more involved though. Main reason is that shortcuts in VS work in scopes so even if you define the same Ctrl + C shortcut as shortcut to a command in your extension (e.g. using method described here How to register key binding code on VSIX package installation) the default Editor Copy command will take precedence over yours and will continue to handle that shortcut. Because your shortcut is considered to be Global scope and the Editor has same shortcut in more specific scope.
To make it work you will need to define the shortcut on the scope of your tool window specifically. This way when your window is focused, VS will give precedence to the scope of your tool window rather than the editor invoking your shortcut as a result.
There are few steps involved in the process you can refer to this answer to see how one developer did it https://stackoverflow.com/a/42899788/633495
An alternative you can consider is to add a small button to your tool window to copy the content without needing to have a shortcut.
I have very old code with a lot of controls. On code behind I can find the name of the control. Now I would like easily by it's name find the placement of it on designer view in Visual Studio (or other tool). Is there any possibility to do it?
No list on mine VS:
Use the document outline pane (Ctrl + Alt + T) which will include searching a little in the document tree, or the ComboBox in the top of properties pane, which is sorted alphabetically.
Screenshot of ComboBox of properties window, closed and opened
not sure if this was what you wanted, and I realise that its an old post BUT:
1 Click on the Form(design) so that you can see your form and the controls.
2 Then click on Properties and just under the Properties title bar you will see a drop-down box. (if you cant see properties then F4)
3 It has a list of all the controls on the form and when you select one, it will take you to that control on the form.
For as long as I can recall, Visual Studio has had an integrate dialog that allows you to easily organize the tab order of your controls.
I've just created my first VS 2012 WinForms project, added all of my controls and went to find the Tab Indexing dialog, and it appears to be missing from Visual Studio.
I found this MSDN article which states that I can open this dialog by going to FORMAT>Tab order. The problem is that there is no Tab Order option on my FORMAT menu. Alternatively, the documentation states th at Ctrl+D should open this dialog. It doesn't.
Another alternative is to select the VIEW>Tab Order menu option. This method causes Tab Index boxes to hover over your controls. You can subsequently click on your controls, one at a time, in the order in which you want them to tab, to set the tab order.
This isn't acceptable because my form contains numerous panels and group boxes that cover one another. It is impossible for me to click-through my controls because many of them are no longer visible in the designer.
Is there an easy way for me to setup the tab order of my controls like there previously use to be within older versions of Visual Studio?
It is still available, you just need to add it back to the View menu. Tools + Customize, Commands tab, Menu bar = View. Select the menu item in Controls where you want to insert it, say the bottom one. Then Add Command, Category = View, Commands = Tab Order.
Your memory of this command does sound a bit hazy, it was never on the Format menu and its never been a dialog. If you want to put it on the Format menu then you can, just pick the Format menu bar in the Commands tab. You can't make it a dialog though, it numbers the controls in the designer view. Some odds that you actually remembered the View + Document Outline command.
Go to your alignment toolbar. At the end, click the tiny little "Add or Remove Buttons" down arrow. Click the "Add or Remove Buttons" button, and look towards the bottom of the list. You should see Tab Order. Click on that and it will be added to the alignment toolbar.
I found this to be very useful http://msdn.microsoft.com/en-us/library/csz6b8x8.aspx
It allows you to simply click on the various controls in the order that you want them to tab through. You do this while you are in the "Show tab order" mode as described above; the tip from Elton about adding the icon to a toolbar makes it easy to toggle the mode.
Ctrl-doubleclick the first control, then click subsequent controls, and press Enter to terminate. You can also start on the Nth control if you Ctrl-click the one before it, then click in order as normal.
(VS Express 2013)
The Tab order tool from the view menu disappears in some cases. For example, if you clikc a text box, then go to its properties, the tab order option will not show. You must select a control, then immediately go to the view menu and choose tab order.
You can click through your controls with the Document Outline view. If they all have the same TabIndex value, their Z-order will be used as tab order. The Z-order can be changed also with the Document Outline view.
In my windows phone 7 app, I would like a "depressed state" when the item is held on as in the themes, accent color setting for my lists. How can this be accomplished?
From this post:
I think the easiest way would be to go
via Expression Blend. Right click on
your ListBox (the main control, not
its items). Then go to "Edit
Additional Templates....(Item
Container Style)....Edit Current".
Blend will then load a new page for
you to modify the styling of the
container. In the top left pane (where
you can choose project, assets etc...)
click on "States". You'll see a list
of states.
Is that what you're looking for?
I believe this was added in a later release of the SDK.
I am trying to create a ToolBar in my WPF application.
I don't want the strip (as shown in the bellow figure) to show up, I just want all the items to be placed in the general area.
I tried setting the ToolBar.OverflowMode to Never ut it doesn't help.
According to Toolbar's control template, there is nothing that can remove that grip. You can set ToolBarTray.IsLocked="True" but this will remove only drag handle from the left hand side. As for the grip you will have to edit default ToolBar template (you can find one in Expression Blend directory, e.g. C:\Program Files\Microsoft Expression\Blend 3\SystemThemes\Wpf\), and remove OverflowGrid from it...