Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign keyboard shortcut to context menu items in report designer

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.

like image 918
adrianm Avatar asked Nov 12 '22 16:11

adrianm


1 Answers

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.

like image 120
Davos Avatar answered Nov 18 '22 17:11

Davos