ComboBox: Set Default Text

Jun 2, 2011 at 1:50 PM


I'm setting up a ribbon for an application and with the combobox controls I need to have the text area default to something on app startup, as right now they are just blank.

I've tried calling combobox.StringValue = myDefaultString when I handle the RibbonComboBox.ItemsSourceReady event. The value is set correctly when looking via the debugger, but the text area is not updated.

I tried adding a call to _ribbon.Framework.InvalidateUICommand() in StringValuePropertiesProvider.StringValue and that did trigger theUpdateProperty method in the StringValuePropertiesProvider but again nothing was updated.

Am I missing something, or is this a bug in the framework?  As I see an example in the Windows Live Movie Maker working and this is kind of a show stopper if I can't get this to work..


Jun 2, 2011 at 11:32 PM

I've tried the following on the C# 06-ComboBox sample:

I've added the following line:

_comboBox2.StringValue = "Label 2";

as the last line of the _comboBox2_ItemsSourceReady method, and it worked.


Jun 3, 2011 at 1:21 AM

Yes, that one worked too, but it doesn't work for _comboBox1 and _comboBox3.

Do you see it work or not work when you do the same for the other two combo boxes?

And yet, that doesn't work for me in my application... :\


Jun 3, 2011 at 1:49 AM

The other two ComboBox have set IsEditable="false", I guess this is the difference.

You can also try to set the SelectedItem (index) of the relevant element, if such exists.

Jun 3, 2011 at 1:55 AM

Ugh, I figured it out.  You have to have IsEditable="true" I had them off because I would prefer the user to not type in them, as input isn't valid for the majority of the items..

Jun 3, 2011 at 1:56 AM

Ah, I didn't refresh the page in between my replies.  I'll try the SelectedItem method too.

Thanks! :)

Jun 3, 2011 at 2:26 AM

Setting the SelectedItem property works great too, after trapping my method to add items & set the index so it doesn't call its self over and over after setting the index. :)

Thanks again!