event BarParentChange (Item as HITEM, Key as Variant, NewItem as HITEM, Cancel as Boolean)
Occurs just before moving a bar from current item to another item.

 TypeDescription 
   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 BarParentChange event notifies your application when a bar is about to be moved from an item to another item. Use the BarParentChange event to control the items where the bar can be moved through the items. The ItemBar(exBarCanMoveToAnother) property specifies whether the user can drag and drop a bar from an item to another item. The ItemBar(exBarCanMove) property specifies whether the user can moves the bar to a new position inside the bar. The ItemBar(exBarParent) property specifies the handle of the item that displays the bar. Use the ItemBar(exBarParent) property to change programmatically the parent of the specified bar. The control fires the BarResize event when the bar is resized or moved to a new position inside the item. The BarParentChange event is fired during the drag and drop operation as soon as the user moves the bar's parent, but it is fired also one more time once the user releases the left mouse button. You can use the GetAsyncKeyState API function to determine whether the left mouse button is pressed or released as in the following VB sample

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)

 


Send comments on this topic.
© 1999-2010 Exontrol.COM, Software. All rights reserved.