Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Ribbon Tech Support » Commands Collapse All
Subject Author Date
Jon Dewalt Oct 7, 2010 - 10:33 AM

I have an external list of optional items that the user may choose from.  This list is read during runtime and populates a contextMenu with a new button for each optional item.  The name and text of each button is set by the optional item name.  This works great.


I also have a sub-procedure that would take the optional item selected by the user and generate a custom control based on the selected item.  This also works great.


I have set up a UI.Command and handler that links the buttons in the context menu with the sub-procedure.


The problem I am having is that the sub-procedure needs to know which button the user selected.  Because  the sender object returns a UI.Command not a Button I added the optional item name to the command.data before i assinged the command to the button.  I thought this would work but when I convert the sender object to a UI.Command, the data object is empty.


Any Suggestions?


Thanks


Jon

Jon Dewalt Oct 7, 2010 - 10:56 AM

I think i found a way to make it work.  I assigned the new button to the command.data after assigning the command to the butt


 For Each md As memMobileDevice In p_MobileDataSystemCollection


   Dim cmd As New Command("DisplayPreConfigured")


   Dim newBut As New Elegant.Ui.Button

   With newBut

        .Name = md.Name

        .Text = md.Name

        .Command = cmd

        .Command.Data = newBut

   End With


   ContextMenu1.Items.Add(newBut)


Next

Technical Support Oct 8, 2010 - 1:22 AM

You can use a CommandExecutedEventArgs class object which is passed to the event handler, it contains the Invoker property which specifies the initiator of the event.