event ButtonClick (Item as HITEM, ColIndex as Long, Key as Variant)
Occurs when user clicks on the cell's button.

TypeDescription
Item as HITEM A long expression that determines the item's handle. If the Item parameter is 0, and the ColIndex property is different than zero, the ColIndex indicates the handle of the cell where the state is changed.
ColIndex as Long A long expression that indicates the column's index, if the Item parameter is not zero, a long expression that indicates the handle of the cell if the Item parameter is 0.
Key as Variant Specifies the button's key that's clicked. If the Key parameter is empty, the user clicked the drop down button of the editor.

Use the ButtonClick event to notify your application that a button is clicked. Use the ColumnClick event to notify your application that the user clicks the column's header. Use the CellImageClick event to notify your application that the user clicks an icon in the cell. You can assign a button to a cell using any of the following ways:

Syntax for ButtonClick event, /NET version, on:

private void ButtonClick(object sender,int Item,int ColIndex,object Key)
{
}

Private Sub ButtonClick(ByVal sender As System.Object,ByVal Item As Integer,ByVal ColIndex As Integer,ByVal Key As Object) Handles ButtonClick
End Sub

Syntax for ButtonClick event, /COM version, on:

private void ButtonClick(object sender, AxEXG2ANTTLib._IG2anttEvents_ButtonClickEvent e)
{
}

void OnButtonClick(long Item,long ColIndex,VARIANT Key)
{
}

void __fastcall ButtonClick(TObject *Sender,Exg2anttlib_tlb::HITEM Item,long ColIndex,Variant Key)
{
}

procedure ButtonClick(ASender: TObject; Item : HITEM;ColIndex : Integer;Key : OleVariant);
begin
end;

procedure ButtonClick(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_ButtonClickEvent);
begin
end;

begin event ButtonClick(long Item,long ColIndex,any Key)
end event ButtonClick

Private Sub ButtonClick(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_ButtonClickEvent) Handles ButtonClick
End Sub

Private Sub ButtonClick(ByVal Item As EXG2ANTTLibCtl.HITEM,ByVal ColIndex As Long,ByVal Key As Variant)
End Sub

Private Sub ButtonClick(ByVal Item As Long,ByVal ColIndex As Long,ByVal Key As Variant)
End Sub

LPARAMETERS Item,ColIndex,Key

PROCEDURE OnButtonClick(oG2antt,Item,ColIndex,Key)
RETURN

Syntax for ButtonClick event, /COM version (others), on:

<SCRIPT EVENT="ButtonClick(Item,ColIndex,Key)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function ButtonClick(Item,ColIndex,Key)
End Function
</SCRIPT>

Procedure OnComButtonClick HITEM llItem Integer llColIndex Variant llKey
	Forward Send OnComButtonClick llItem llColIndex llKey
End_Procedure

METHOD OCX_ButtonClick(Item,ColIndex,Key) CLASS MainDialog
RETURN NIL

void onEvent_ButtonClick(int _Item,int _ColIndex,COMVariant _Key)
{
}

function ButtonClick as v (Item as OLE::Exontrol.G2antt.1::HITEM,ColIndex as N,Key as A)
end function

function nativeObject_ButtonClick(Item,ColIndex,Key)
return

The following VB sample displays the key of the button being clicked:

With G2antt1.Columns.Add("Editor").Editor
    .EditType = EditType
    .AddButton "Key1", 1
    .AddButton "Key2", 2, EXG2ANTTLibCtl.AlignmentEnum.RightAlignment, "This is a bit of text that should be displayed when the cursor is over the button", "Some information"
    .AddButton "Key3", 3, EXG2ANTTLibCtl.AlignmentEnum.RightAlignment
End With
...
Private Sub G2antt1_ButtonClick(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal Key As Variant)
    ' Displays the button's key that was clicked
    Dim mes As String
    mes = "You have pressed the button"
    mes = mes + IIf(Len(Key) = 0, "", " '" & Key & "'")
    mes = mes + " of cell '" & G2antt1.Items.CellValue(Item) & "'."
    Debug.Print mes
End Sub

The following VB sample displays the caption of the cell where a button is clicked:

Private Sub G2antt1_ButtonClick(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal Key As Variant)
    With G2antt1.Items
        Debug.Print .CellValue(Item, ColIndex) & ", Key = '" & Key & "'"
    End With
End Sub

The following C++ sample displays the caption of the cell where a button is clicked:

#include "Items.h"
void OnButtonClickG2antt1(long Item, long ColIndex, const VARIANT FAR& Key) 
{
	CItems items = m_g2antt.GetItems();
	CString strFormat;
	strFormat.Format( "%s, Key = '%s'", items.GetCellValue( COleVariant( Item ), COleVariant( ColIndex ) ), V2S( (LPVARIANT)&Key ) );
	OutputDebugString( strFormat );
}

where the V2S string may look like follows:

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}

or

static string V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		CComVariant vt;
		if ( SUCCEEDED( vt.ChangeType( VT_BSTR, pv ) ) )
		{
			USES_CONVERSION;
			return OLE2T(V_BSTR( &vt ));
		}
	}
	return szDefault;
}

if you are using STL.

The following VB.NET sample displays the caption of the cell where a button is clicked:

Private Sub AxG2antt1_ButtonClick(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_ButtonClickEvent) Handles AxG2antt1.ButtonClick
    With AxG2antt1.Items
        Dim strKey As String = ""
        If Not (e.key Is Nothing) Then
            strKey = e.key.ToString()
        End If
        Debug.Print(.CellValue(e.item, e.colIndex).ToString() + ", Key = " + strKey)
    End With
End Sub

The following C# sample displays the caption of the cell where a button is clicked:

private void axG2antt1_ButtonClick(object sender, AxEXG2ANTTLib._IG2anttEvents_ButtonClickEvent e)
{
	string strKey = "";
	if (e.key != null)
		strKey = e.key.ToString();
	System.Diagnostics.Debug.WriteLine(axG2antt1.Items.get_CellValue(e.item, e.colIndex) + ", Key = " + strKey);
}

The following VFP sample displays the caption of the cell where a button is clicked:

*** ActiveX Control Event ***
LPARAMETERS item, colindex, key

with thisform.G2antt1.Items
	.DefaultItem = item
	wait window nowait .CellValue(0, colindex)
endwith