iRibbon dropDown Control

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
How does one clear the selection of a custom dropDown control in teh ribbon? Or alternatively, how does one fire the onAction procedure when the user selects the same member of teh list again?

Has anyone else noticed this? When using a drpDown control in teh ribbon, the user selects a member of te list, which fires the onAction procedure. As expected. Teh user selects a different member of teh list, and again, it behaves as expected. But when the user expands teh list, and re-select the same member as is currently selected, teh list collapses, and the onAction procedure is never called. I'm not even sure how to cludge this other than telling te huser to select something else, then click what he wants...
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Use its getText callback to clear it and have the onAction code invalidate the control at the end.
 
Upvote 0
Use its getText callback to clear it and have the onAction code invalidate the control at the end.

From what I can see, the only control that has a getText attribute is an editBox. dropDown does not seem to support this.
 
Upvote 0
Sorry - I misread the question and thought you were using a combobox (lots of controls have getText by the way). For a dropDown you need the getSelectedItemID or getSelectedItemIndex callback:
Code:
'Callback for cboSAPCodes getSelectedItemIndex
Sub getComboIndex(control As IRibbonControl, ByRef returnedVal)
   returnedVal = -1
End Sub
then invalidate at the end of the onAction callback to clear the item.
 
Upvote 0
Just for completeness, according to 'RibbonX, Customizing the Office 2007 Ribbon' by Martin, Puls and Hennig, the getSelectedItemIndex attribute of the dropDown control allows return values of 1 to 1024, so -1 raises an error. That being said, a little experimentation showed that this is a 0-based collection... Not to worry, I simply added a dummy entry of (select) at position 1, and return a value 0.
 
Upvote 0
Curious - using -1 seemed to work in my sample.
 
Upvote 0
Nope, using 1 returned the second item in my list. I had to swap to 0 to get the first item. I also thought this was strange. Perhaps I need to test this on a couple of computrs before I distribute...
 
Upvote 0
-1 not 1
I confess I assumed that as it's what you'd use with any other combo or listbox.
 
Upvote 0
Your response on my other thread reminded me I hadn't thanked you. THANX!

On another dropDown I'm working with: Can you think of any reason why getSelectedItemID wouldn't work? I mean, I put the code in the XML, and it's like the line doesn't get parsed at all. It doesn't return an error, and it doesn't get called either during load or when I invalidate the control. I got what I needed using getSelectedItemIndex, but I'm bothered by the fact that my first pass just didn;t work...
 
Upvote 0
What does the actual XML look like? (I assume you are validating it in the CustomUI editor or whatever you are using?)
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,314
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top