Skip to content

phoContextMenuColumn - cCJGrid

Contains the handle of the last column object selected for a context menu

Type: Property
Access: Read/Write
Data Type: Handle
Parameters: None

Syntax

Property Handle phoContextMenuColumn
Access Type Syntax
Read Access: Get phoContextMenuColumn to HandleVariable
Write Access: Set phoContextMenuColumn to HandleVariable/Value

Description

When you right-click on a column's header or cell, a context menu may be invoked. When a context menu item is selected, the processing logic may need to know which column invoked the menu. If you select the menu from a data cell and you allow cell-level focus (pbFocusSubItems is True), you can use SelectedColumnObject to determine the column. If you select the menu from the header or pbFocusSubItems is False, you need a way to know which column invoked the context menu. phoContextMenuColumn provides this information.

Both the OnRowRightClick and OnHeaderRightClick events set this property before invoking a context menu. You then use this property in your context menus.

Sample

This example shows how the cCJGridFreezeColumnMenuItem class uses phoContextMenuColumn to determine which column should be left frozen. Note that the focus object is the grid. Also note that it is possible that a context menu may be invoked for no column at all (clicking on right side empty space), in which case phoContextMenuColumn will be zero. This must be tested.

Class cCJGridFreezeColumnMenuItem is a cCJMenuItem

    Procedure Construct_Object
        Forward Send Construct_Object
        Set psCaption to C_$FreezeUnFreeze
    End_Procedure

    Procedure OnExecute Variant vCommandBarControl
        Handle hoFocus hoCol

        Get Focus to hoFocus
        Get phoContextMenuColumn of hoFocus to hoCol
        Send FreezeColumn of hoFocus hoCol
    End_Procedure

    Function IsVisible Returns Boolean
        Handle hoFocus
        Boolean bAuto
        Handle hoCol

        Get Focus to hoFocus
        Get phoContextMenuColumn of hoFocus to hoCol
        Get pbAutoColumnSizing of hoFocus to bAuto
        Function_Return (hoCol<>0 and not(bAuto))
    End_Function

    Function IsEnabled Returns Boolean
        Handle hoFocus
        Handle hoCol

        Get Focus to hoFocus
        Get phoContextMenuColumn of hoFocus to hoCol
        Function_Return (hoCol)
    End_Function

End_Class