Ribbon Combo Box

croydon

Registered User.
Local time
Today, 04:12
Joined
Oct 12, 2006
Messages
22
I have a ribbon containing a combo box. When a selection is made, the callback runs the function correctly. However, the selected item remains selected in the combo. This means that it cannot be selected (clicked) again, unless another item is selected first.

Is there a way to clear the selection as with a normal form-based combo box?

Any help would be appreciated.
 
Thanks for the suggestion, but there doesn't seem to be a way of doing this.
 
Hi

The secret is in the use of InvalidateControl

'Rewrites and updates the list of the combobox to a new search.
objRibbon.InvalidateControl ("cbx1")

Review article code.
 
Last edited:
Hi

The secret is in the use of InvalidateControl

'Rewrites and updates the list of the combobox to a new search.
objRibbon.InvalidateControl ("cbx1")

Review article code.

Hi

Correct me if I'm wrong ( as I don't have means to test right now ) but in order to successfully invalidate a ribbon object, you would have to change its value? Merely invalidating wouldn't necessarily clear it's contents?

Cheers

Nidge
 
HI Croydon!

Case resolved ?
 
Not really. I come back to the problem occasionally to try resolve it.

By using InvalidateControl and setting the getText callback to "", I can blank the selection made in the combo. However, the index is still set (the previous selection is still highlighted) which stops that item being selected again.

I thought maybe setting the GetItemId callback to "0" might resolve this, but the callback does not appear to fire.
 
Hi,

can you post or send me a sample? i can only think that is something simple as i have combos that work fine.

I'll have a look and compare it with mine to see where the problems are.

you can email me

nigel at acccis dot co dot uk :)

cheers
 
Maybe you want to be using a menu instead of a drop down?
 
It seems that a menu would suit his needs better. I've had the same issue though, and switching to a menu resolved it.
 
Nigel, thanks for the offer.

Before I do that, could you tell me what callbacks you have on your combo boxes?

In my case, the 'onChange' event runs a function to determine the macro to run or form to open. This works correctly, but as I say, leaves the selection name in the combo text and the item highlighted when the combo is opened again

I have tried running InvalidateControl at the end of the function.

I have also tried using the callback 'getText' and returning "" to the combo. This blanks the text but the previous selection is still highlighted. I thought using 'getItemId' to set the index to zero might resolve the issue but I can't get the callback to fire.

Thanks for your help.
 
I think I now understand what is going on.

The combo boxes were defined with their individual items in the ribbon record. They did not refresh.

As a test, I tried storing the items for one combo in a table and populating the combo using the getItemCount, getItemLabel and getItemImage callbacks. InvalidateControl then refreshed the ribbon and I was able to select the same item repeatedly, as required.

Unfortunately, I now have a problem with getItemImage. When I try to load an imageMso it always displays a large image. The code for this is below:

Sub GetComboImage(control As IRibbonControl, index As Integer, ByRef Image)
Dim cmd As New adodb.Command, rs1 As adodb.Recordset

Set rs1 = New adodb.Recordset
rs1.Open "SELECT Image FROM tblRibbonCombos WHERE Combo = '" & control.ID & "' AND SortOrder = " & index, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly

If rs1.EOF = False Then
rs1.MoveFirst
Image = rs1("Image")
End If

rs1.Close
Set rs1 = Nothing
End Sub

For the other Combos that are defined with their individual items in the uSysRibbons record using the imageMso property (e.g. imageMso="ExportExcel"), these are displayed as small images.

Any assistance would be appreciated. Thanks.
 
Hi,

in your ribbon XML, you might need to add in Size="Small" to make the mso image smaller. Im not sure if this can be done by code though.

let me know how you get on


cheers

Nidge
 
If rs1.EOF = False Then
rs1.MoveFirst
Image = rs1("Image")
End If

I have always preferred-

Code:
With rs1
If Not .EOF Or .BOF Then
.MoveFirst
End If
End With


cheers


Nidge
 
Nidge, Unfortunately, 'Size' cannot be applied to a ComboBox.
 
Hi,

i hadent checked it. Maybe your images are too big? i think they have to be 16 x 16 for a small ribbon icon but its worth checking. It will be a simple thing only :)


cheers


Nidge
 

Users who are viewing this thread

Back
Top Bottom