3

I am writing a Visual Studio extension and I need to programmatically open the Tools->Options dialog on a specific page.

I could find how to open the dialog on the default page:

var editor = (my_package as System.IServiceProvider).GetService(typeof(DTE)) as DTE2;
editor.ExecuteCommand("Tools.Options");

I have found that I can pass some parameter after the command name. But passing the specific page name I want does not seem to do the trick.

  • Is it even possible to open a specific page?
  • Is there some specific grammar to give the expected page name?
  • Is there some better practice to do that instead of using editor.ExecuteCommand?
Stephane
  • 333
  • 1
  • 13
  • If what you mean is to open the specific page in Tools=>Options such like opening Tools=>Options=>Text Editor, maybe you can get some help from [this document](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/cc826083%28v%3dvs.120%29#to-display-an-options-page-that-is-defined-by-visual-studio), but it's too old, so i'm not sure if VS2017 and higher version support for this behavior. – LoLance Jun 26 '19 at 08:56
  • Hi Lance! Thanks for your very quick answer! That makes the trick for me, it is still working for VS2017 ;-) – Stephane Jun 26 '19 at 09:40
  • Actually that's too old.(Can't find related topic in recent document) Maybe you can get the Guid in [this way](https://stackoverflow.com/questions/49341650/visual-studio-extensions-calling-options-window-and-id-for-test-menu). – LoLance Jun 26 '19 at 09:41
  • That still works for me: I was trying to open a custom option page. Maybe this is slightly different when trying to open an options page defined by Visual Studio... – Stephane Jun 26 '19 at 09:45

1 Answers1

1

Following Lance's answer, for me it gives:

myVSPackage.ShowOptionPage(typeof(myOptionPage));
Stephane
  • 333
  • 1
  • 13
  • Hi Stephane, thanks for your sharing and please mark your reply as answer and that will help other community members who easier search this useful information, it just a reminder :) – LoLance Jun 28 '19 at 01:54