I haven't actually done this in VSTO, but I've done similar with VBA callbacks and the dropDown
control. The following is how I would do it, only the callbacks would be to VBA instead of VB.NET (untested!)
Define callbacks for your comboboxes:
Use getItemCount
, getItemID
and getItemLabel
to define the contents of the comboboxes - you will have to use some kind of state to know how to fill the values in the second combo based on the contents from the first.
Use the onChange
callback on the first combo to trigger an invalidation of the second combo. You use a reference to the ribbon and call Invalidate
to reload the entire ribbon och InvalidateControl(id)
to invalidate a specific control (e.g. the second combo)
If you cannot get this to work I recommend the dropDown control, which has a few more callbacks available and better control (the onAction
callback defines an index for the selection, instead of a string like the comboBox onChange
).
The VB.NET-signatures for the callbacks mentioned above:
Function GetItemCount(control As IRibbonControl) as Integer
Function GetItemID(control As IRibbonControl, itemIndex as Integer) as String
Function GetItemLabel(control As IRibbonControl, itemIndex as Integer) as String
Sub OnChange(control As IRibbonControl, text As String)