5

I'm currently creating some reports in BIDS (SQL Server 2008 R2, VS2008).

I feel that I constantly need to access the dialogs Expression... and Textbox properties... in the designer

textbox context menu

but it slows me down to use the mouse and context menu all the time. (They are not even the top items in the menu!) It is even worse with the keypad on my laptop which unfortunately does not have the context menu button.

Is there a way to assign keyboard shortcuts (like CTRL1 & CTRL2) to these dialogs?

I have tried to find them in the keyboard customization dialog and even tried to record a macro but nothing works.

The closest I got is ShiftF10E and ShiftF10P but for that I need both hands.

I got it to work the last time I worked with reports some years ago in VS2005.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
adrianm
  • 14,468
  • 5
  • 55
  • 102
  • MSDN has an article at [http://msdn.microsoft.com/en-us/library/ms173782(v=sql.105).aspx] which explains how to customise keyboard shortcuts in BIDS – thomasswilliams Jan 04 '13 at 03:45
  • @thomasswilliams Your link does not work but I assume you mean the page where it says I should use the keyboard customization dialog. My question is how I find the above two menu items in that dialog. – adrianm Jan 07 '13 at 09:20
  • Whoops, my habits for wiki markup creeping in - SO includes the trailing square bracket in the link http://msdn.microsoft.com/en-us/library/ms173782(v=sql.105).aspx – thomasswilliams Jan 08 '13 at 01:47
  • However that page includes nothing for "Expression" and "Text Box Properties" keyboard shortcuts. Your solution of SHIFT+F10+E etc. might be the best/only option – thomasswilliams Jan 08 '13 at 01:50

1 Answers1

1

Usually with shortcuts in Visual Studio (BIDS), you can go Tools --> Options --> Environment --> Keyboard

If you filter the list of commands to make the list shorter, you can find the command you want and click into the "Press shortcut keys:" text box and then press the shortcut combination you want.

I tried that and everything related to Expression didn't work :( . Basically it's pretty hard to know what all those commands are and hard to find the one you want.

But there's another option. It's a bit round-a-bout but it works fine. It basically involves creating a macro which will send shift-F10-E to your active context and then binding that macro to your shortcut keys of choice, e.g. CTRL-1. I'm using Visual Studio 2008 (installed from SQL Server 2008R2 disk)

1) Show the macro window by selecting View--> Other windows --> Macro Explorer

2) Create a new module under "MyMacros"

3) Enter this VB.NET code:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module UserShortcuts
    Public Sub ShowExpression()
        System.Windows.Forms.SendKeys.SendWait("+{F10}E")
    End Sub
End Module

4) Go to Tools --> Options --> Environment --> Keyboard

5) Type "macros" into the "Show commands containing:" textbox and the sub as defined in the module in the code above will appear and you can highlight it.

6) You can then select the "Press shortcut keys" textbox and type [CTRL] + 1 or whatever you like and then click the [Assign] button.

7) This MSDN page shows all the key options you can choose for the SendWait method. If you want to add more keyboard shortcuts, just add more Sub() entries in the module for each one and then map them as per steps 4 to 6.

I've written an expanded version of this solution here.

Davos
  • 5,066
  • 42
  • 66
  • Thanks. This works fine as long as the cell is selected. Unfortunately BIDS has a tendency to start editing the cell when you click on it and then the macro does not work for some reason. Tried with a small delay without luck. I will use it anyway. – adrianm Jan 31 '13 at 09:33
  • The menu is always context sensitive so depends on the cell you have selected. Clicking on the cell can certainly be fiddly and yes you have to click on the cell without clicking in to it for this to work. The way to do that is to not click on the part of the cell where the text within it is visible. Click on part of the cell that is empty once and it will select the cell, twice and it will go into the cell. Click once on the cell where the text is and it will go straight into the cell. – Davos Feb 01 '13 at 02:43
  • I know how to select the cell. The strange thing is that if I happen to get into edit mode the context menu opens but "Expression" is not selected even if it is available. Not your fault of course and I am very happy with your solution. – adrianm Feb 01 '13 at 10:16