![]() | Type | Description | ||
| Item as HITEM | A long expression that specifies the owner item ( the handle ) that displays the bar being moved. | |||
| Key as Variant | A string/variant expression that specifies the key of the bar being moved. | |||
| NewItem as HITEM | A long expression that specifies the handle of the item where the bar is going to be moved. | |||
| Cancel as Boolean | A boolean expression that indicates where the bar can be moved from Item to NewItem. By default, the Cancel parameter is False, so the bar can be moved to any item that does not contain another bar with the same key. Handle the event, and change the Cancel parameter to False, if you need to prevent moving a bar to NewItem item. |
The following screen shot shows few options to move, limit or resize bars:

The screen show was generate using the following x-script template ( the visual appearance code was excluded ):
The following VB sample prevents moving the bar to selectable items only ( SelectableItem property ):
Private Sub G2antt1_BarParentChange(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant, ByVal NewItem As EXG2ANTTLibCtl.HITEM, Cancel As Boolean)
With G2antt1.Items
Cancel = Not .SelectableItem(NewItem)
End With
End Sub
The following VB.NET sample prevents moving the bar to selectable items only ( SelectableItem property ):
Private Sub AxG2antt1_BarParentChange(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_BarParentChangeEvent) Handles AxG2antt1.BarParentChange
With AxG2antt1.Items
e.cancel = Not .SelectableItem(e.newItem)
End With
End Sub
The following C# sample prevents moving the bar to selectable items only ( SelectableItem property ):
private void axG2antt1_BarParentChange(object sender, AxEXG2ANTTLib._IG2anttEvents_BarParentChangeEvent e)
{
e.cancel = !axG2antt1.Items.get_SelectableItem(e.newItem);
}
The following C++ sample prevents moving the bar to selectable items only ( SelectableItem property ):
#include "Items.h"
void OnBarParentChangeG2antt1(long Item, const VARIANT FAR& Key, long NewItem, BOOL FAR* Cancel)
{
*Cancel = !m_g2antt.GetItems().GetSelectableItem( NewItem );
}
The following VFP sample prevents moving the bar to selectable items only ( SelectableItem property ):
*** ActiveX Control Event *** LPARAMETERS item, key, newitem, cancel cancel = !thisform.G2antt1.Items.SelectableItem(newitem)