Populating a combo box within the Ribbon from a Database

Z

Zathras

I can see how to load the contents of a combo box from the XML file. What I
have is a database. One of the tables (call it CompanyList) has a list of
companies and I have a stored procedure called CompaniesRetrieveAll.

I need to populate the Combobox from here.

Anyone got any ideas how this is done.

Ta in advance

Paul
 
P

Patrick Schmid

Hi Paul,

You can implement this by implementing the two callbacks "getItemCount"
and "getItemLabel" for the comboBox. For an example of a COM add-in
implementing those two, see my following blog post:
http://pschmid.net/blog/2006/06/14/21
Let me know if this helps. If not, just post again with more questions
:)

Patrick Schmid
 
Z

Zathras

Ta

First reaction is Yuk! Mostly because I have a DataTable and it looks like
this needs to be at class scope rather than in a function. I was hoping one
could just access the combo in the load event of the Ribbon.

Oh well!

Will post the code when I've written it, if only for others

Thanks and Regards

Paul
 
Z

Zathras

Worded it out now.

For those who may not have figured it out and are having difficulty.

The following is the XML to define the Ribbon;

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="OnLoad">
<ribbon startFromScratch="false">
<tabs>
<tab id="Accounting.Tab" label="Accounting" visible="1">
<group id="AccountingConnection.Group" label="Connection" visible="1">
<comboBox id="lstCompanies"
label="Connect To:"
visible="1"
getItemCount="lstCompanies_GetItemCount"
getItemLabel="lstCompanies_GetItemLabel"
screentip="Select which company you wish to work with"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

and the code to deal with the callbacks

Public Function lstCompanies_GetItemCount(ByVal control As
Office.IRibbonControl) As Integer
Return 1
End Function

Public Function lstCompanies_GetItemLabel(ByVal control As
Office.IRibbonControl, ByVal Index As Integer) As String
Return "Your Co"
End Function
 

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