How to find item in DropDownGallery (commands)

Sep 21, 2010 at 2:20 PM

Hi, 1st of all, thanks for your hard work, a nice pice of software. :)

One short quesiton: I've made a standard DropDownButtonGallery (Commands), works well, all ribbonbuttons have their own image, labeltext and so on...

In my code, i've added an execute handler to each button in array (based on your splitbutton ex. source):

        For i = 0 To mybuttons.Length - 1
            mybuttons(i) = New RibbonButton(myribbon, 6000 + i)
            With mybuttons(i)
                .Label = Button & i
                .LargeImage = myribbon.ConvertToUIImage(CType(imageListGhosts.Images(CInt(Fix(i))), Bitmap))
                .LabelDescription = "Test"
                .TooltipDescription = "TT_Test"
                .TooltipTitle = .Label
                AddHandler .OnExecute, AddressOf execute_mybutton
            End With
        Next i

blabla... will be added to Gallery ... blabla... all ok till here.

Problem: What's the correct way in Sub "execute_mybutton" to find out which one of my dynamically added buttons (or THE button in my buttonarray) has been clicked (e. x. messagebox with buttons labeltext...)? Im a little confused between the differences with the other gallerytype (items)... e. x. "selecteditem" for a command is also present, but always returns 0...?!?

Thanks for your help.

best regards

Jordan

Coordinator
Oct 21, 2010 at 10:59 PM

First, sorry for the late reply.

The events mechanism has changed and supports the more standard "object sender, MyEventArgs e" syntax.
Using the sender you can check which button generated the event.