I have a customized Ribbon in Word. The Ribbon has one comboBox: comboBox_recentConditions which was defined using the Designer - so it's initalized and is empty at load. Now, I would like to dynamically set this comboBox each time the Application_WindowActivate event is fired.
Each Word document has its own instance of class called RibbonControls:
class RibbonControls
{
private RibbonComboBox recentConditionComboBox;
public RibbonControls()
{
this.recentConditionComboBox = new RibbonComboBox();
}
public RibbonComboBox RecentConditionComboBox
{
get
{
return recentConditionComboBox;
}
set
{
recentConditionComboBox = value;
}
}
}
Now in Application_WindowActivate event i do the following:
static void Application_WindowActivate(Document doc, Window Wn)
{
Globals.Ribbons.SourceRibbon.comboBox_recentConditions = WordGate.docRibbonControls.RecentConditionComboBox;
}
The problem is that the Ribbon comboBox control doesn't changes, it's always empty, even after Application_WindowActivate is called. I tested at run-time to see if each document indeed has its own comboBox with its items - which seems to work. What am I missing?
To clear my question: Let's say I have 3 items in the comboBox.Items. When clicking on it I see nothing, but if I add this:
MessageBox.Show(Globals.Ribbons.SourceRibbon.comboBox_recentConditions.Items.Count.ToString());
at the end of Application_WindowActivate
it will print the number 3.
Thanks.