How to add code when a menu option is clicked

This guide explains how to execute custom code when an item is clicked in both K2BAccordionMenu and K2BHorizontalMenu.

Steps to add code on item click

  1. Define a variable for the Selected Item
    • Create a variable (e.g., &SelectedItem) of type Character. This variable will hold the code of the selected item.
  2. Bind the Variable to the User Control's SelectedItem Property
    • Assign the &SelectedItem variable to the SelectedItem property of the user control.
      SelectedItemVariableInUC
      SelectedItem variable in the user control properties

  3. Implement the OptionClicked Event
    • Implement the event UCControlName.OptionClicked
      • Handle the UCControlName.OptionClicked event in your code. Within this event, you can use the &SelectedItem variable to access the code of the selected item.
        CodePropertyMenu
        Code property of menu

        Example
        Event K2BAccordionMenu1.OptionClicked
        	
        	msg("The selected item is:"  + &Selecteditem)
        
        EndEvent
        

Availability

  • In K2BHorizontalMenu from version 12.0
  • In K2BAccordionMenu from version 15.2