How to populate vsct combo (B) based on the value chosen in combo (A)

Hugo Machado 1 Reputation point
2022-02-24T11:57:27.773+00:00

I am developing an extension for Visual Studio 2022 and I have two vsct combos of type DynamicCombo added in my extension's toolbar:

<Combos>
   <Combo guid="guidPackageCmdSet" id="comboA" priority="0x0012" type="DynamicCombo" defaultWidth="240" idCommandList="comboAGetList">
       <Parent guid="guidPackageCmdSet" id="TWToolbarGroup"/>
       <CommandFlag>IconAndText</CommandFlag>
       <CommandFlag>CommandWellOnly</CommandFlag>
       <Strings>
           <ButtonText>Combo A: </ButtonText>
       </Strings>
   </Combo>
   <Combo guid="guidPackageCmdSet" id="comboB" priority="0x0013" type="DynamicCombo" defaultWidth="240" idCommandList="comboBGetList">
       <Parent guid="guidPackageCmdSet" id="TWToolbarGroup"/>
       <CommandFlag>IconAndText</CommandFlag>
       <CommandFlag>CommandWellOnly</CommandFlag>
       <Strings>
           <ButtonText>Combo B: </ButtonText>
       </Strings>
   </Combo>
<Combos>

I've created commands for each combobox to load values and handle the on change event.

  1. Is there any way to populate the comboB after changing the value on comboA? I need to populate the comboB based on the value chosen in comboA. Is that possible?
  2. Is it possible to load these combos with an array of my objects? I would need to display a NAME but when I change the value, I need its ID.

Thanks in advance.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,933 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.