CommandBarComboBox.Change doesn't fire

G

geejay

I have this code:

namespace VisioAddIn1
{
public partial class ThisAddIn
{

private Microsoft.Office.Core.CommandBar CustomToolCommandBar;
private Microsoft.Office.Core.CommandBarComboBox myCombo;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{


CustomToolCommandBar =
((Office.CommandBars)this.Application.CommandBars).Add(
"My Custom Tool Bar", Office.MsoBarPosition.msoBarTop,
false, true) as Office.CommandBar;
myCombo =
(Microsoft.Office.Core.CommandBarComboBox)CustomToolCommandBar.Controls.Add
(Microsoft.Office.Core.MsoControlType.msoControlComboBox,
missing, missing, missing, true);
myCombo.Style = Microsoft.Office.Core.MsoComboStyle.msoComboLabel;


myCombo.Caption = "Test Combo";
myCombo.Tag = "TESTCOMBO";
myCombo.AddItem("One", 1);
myCombo.AddItem("Two", 2);
myCombo.AddItem("Three", 3);
myCombo.Visible = true;
myCombo.Change += new
Microsoft.Office.Core._CommandBarComboBoxEvents_ChangeEventHandler(myCombo_Change);
}

void myCombo_Change(Office.CommandBarComboBox Ctrl)
{

}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}

#region VSTO generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}

#endregion
}
}

But the combobox, when changed, does not fire the event.

What's the deal? Are there any alternatives/work arounds?

I don't really need a ComboBox, I would prefer a simple drop down.

Thanks for any help
 
G

geejay

ok, update, it seems to work if I don't add a document to the visio
application.

Does anyone know why this would make a difference? why it would work when
the drawing area is empty (ie the "first steps with visio" page)?
 
G

geejay

Ok, I found a workaround.

Instead of using the ComboBox (i really just wanted a dropdown), I used a
CommandBarPopup control. Its not the same, but at least the events fire when
I open up a document!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top