Dynamically add items to editable ComboBox in Ribbon

S

SanjaDj

I would like to use editable combobox in Ribbon for the selection of WebSites.
Using GetItemCount And GetItem Label I will add standard used (and saved in
xml) items but I would like to be able to add to xml new website, the one
that user type in.
When user change selection to one of the already existing items I would like
that new item (the one that is typed in) remains in the list.

How can I make this?
Thanks in advance.
 
X

XL-Dennis

Hi Sanja,

If You make us of a standalone XML file then You can handle it as a
textfile, in that way You can read from it and aslo write to it.
 
S

SanjaDj

Hi Dennis,
Thanks for your answer but I still don’t know how to make use of the value
that user type in editable combo box.

Namely, how can I refresh combobox list with that new value and how (when)
to write that value in the xml file where
I would like to keep history.
Also I don’t know how to set initial value in the combbox to the last one
used, assuming that last used it is stored in xml file as well.

Here is code I have so far

In Ribbon1.xml I have:
<comboBox id="ServiceLocationComboBox"
label="Service Location" showLabel="true"
sizeString="WWWWWWWWWWWWWWWWWWWWWWWWWW"
getItemCount="GetItemCount" getItemLabel="GetItemLabel">
</comboBox>


In Ribbon1.vb:
Private WebSitesList As ArrayList

Public Sub OnLoad(ByVal ribbonUI As IRibbonUI)
Me.ribbon = ribbonUI

‘Note: In ReadWebSitesHistory I read history of used websites from xml file.

WebSitesList = ReadWebSitesHistory()
End Sub



Function GetItemCount(ByVal control As IRibbonControl) As Integer
If control.Id = "ServiceLocationComboBox" Then
Return WebSitesList.Count
End If
Return 0
End Function

Public Function GetItemLabel(ByVal control As IRibbonControl, ByVal index
As Integer) As String
If control.Id = "ServiceLocationComboBox" Then
Return WebSitesList(index).ToString
End If
Return ""
End Function


Kind regards,
Sanja
 

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