Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding values to a combo element in Visual Studio Extension

I'm trying to create a custom visual studio extension. It involves a toolbar, with a combo element, which I want to populate programatically.

I made the toolbar and combo box in the vsct, but I'm not sure how to get a reference to it in the code and add items to it.

I have this, where do I go from here?

CommandID commandId = new CommandID(GuidList.guidExtensionCmdSet, (int) PkgCmdIDList.cmdMyDropdown);
like image 360
Erik W Avatar asked Oct 21 '25 19:10

Erik W


1 Answers

Assuming that cmdMyDropdown is the commandId for your dropdown, you then need to create an OleMenuCommand and add it to the OleMenyCommandService.

OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
CommandID commandId = new CommandID(GuidList.guidExtensionCmdSet, (int) PkgCmdIDList.cmdMyDropdown);
OleMenuCommand menuMyDynamicComboCommand = new OleMenuCommand(new EventHandler(OnMenuWorkorderDropdown), commandId);
mcs.AddCommand(menuMyDynamicComboCommand);

In your event, you then have to use

Marshal.GetNativeVariantForObject(String[] yourValues, OleMenuCmdEventArgs.OutValue);

OutValue is the dropdown reference that gets passed.

Read more here: http://dotneteers.net/blogs/divedeeper/archive/2008/07/14/LearnVSXNowPart25.aspx

like image 148
Ben Avatar answered Oct 24 '25 09:10

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!