Ashish Dwivedi

Hi,

I have added a combobox to my outlook ribbon. I am able to add items to the combobox using the following code:-
<comboBox onChange ="OnChange" id="cmbCase" >
<item id="itmMech" label="Mechnical"/>
</comboBox>

While i can add item using the above code i need to add the items dynamically wherein i will be getting items from the database.

Any help will be highly appreciated .

Thanks in Advance
Ashish




Re: Visual Studio Tools for Office How to add items to combobox/dropdown dynamically?

X4U

Hello Ashish,

you need to define the callbacks that would be called when your Ribbon is created in the XML file.

It should look like this:

<comboBox

id="cmbCase"

showLabel="true"

imageMso="PictureEffectsGlowGallery"

getItemImage="ComboBoxGetItemImage"

getItemCount="ComboBoxGetItemCount"

getItemLabel="ComboBoxGetItemLabel"

getItemScreentip="ComboBoxGetItemScreentip"

getItemSupertip="ComboBoxGetItemSupertip"

getItemID="ComboBoxGetItemID"

onChange="ComboBoxOnChange"

sizeString= "XXXXXXXXXXXX"

getText="ComboBoxGetText">

</comboBox>

Here is the Information how the Callback method signatures looks like:

http://msdn2.microsoft.com/en-us/library/aa722523.aspx

So, when your Ribbon is loaded, I would define a collection within the Ribbon.cs class and load the data for the ComboBox in the construcion code.

Then access this data from the callbacks - or request the data from the database on every function callback.

It's a runtime decision.

e.g. the "ComboBoxGetItemCount" will look like this:

public void CallbackCBGetItemCount(Office.IRibbonControl control, ref count)

{

// passes the number of Items in the collection to the combobox

switch( control.ID)

{

case "cmbCase":

count = _ItemsFromDatabase.Count ;

break;

}

}

Hope this helps,

greets, Helmut






Re: Visual Studio Tools for Office How to add items to combobox/dropdown dynamically?

csr9632

Hi,

I have added a font combobox to my excel ribbon. I am able to add it using the following code:

<comboBox idMso="Font" sizeString="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />

But the length of the font combo box was short.

How can I extend it

Please help me!!!