property HostContext.Bar as Variant
Returns the key of the bar from the current cursor location.

TypeDescription
Variant A Variant expression that specifies the key/identifier of the task from the current cursor location.
The Bar property returns a valid value, while the HitTest property includes the exHTValidBar. As each task is assigned to an item, if the exHTValidItem is automatically set on the HitTest property, if the exHTValidBar is present. The ItemBar property of the Items object, specifies a property of the task, like colors, start and end margins, and so on. The Item property returns the handle of the item from the current cursor location. The exHTValidBar may occur while the cursor hovers the chart/tasks section of the control.

The following sample changes the color of the task's frame, when the user right clicks the control:

Private Sub G2Host1_Context()
    With G2Host1
        If (.HostContext.HitTest And exHTValidBar) Then
            .Host.Items.ItemBar(.HostContext.Item, .HostContext.Bar, EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarFrameColor) = RGB(255, 0, 0)
        End If
    End With
End Sub