Type | Description | |||
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:
The CellHasButton property specifies whether the cell displays a button. Use the CellValue property indicates the button's caption. In this case the Key parameter is empty.
The AddButton method adds a button to an editor. The Key parameter indicates the key of the button being clicked. A drop down type editor like ButtonType, DropDownType, DropDownListType, PickEditType, DateType, ColorType, FontType and PictureType includes a drop down button. The Key parameter is empty, for a drop down button.
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 |
private void ButtonClick(object sender, AxEXGRIDLib._IGridEvents_ButtonClickEvent e) { } void OnButtonClick(long Item,long ColIndex,VARIANT Key) { } void __fastcall ButtonClick(TObject *Sender,Exgridlib_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: AxEXGRIDLib._IGridEvents_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 AxEXGRIDLib._IGridEvents_ButtonClickEvent) Handles ButtonClick End Sub Private Sub ButtonClick(ByVal Item As EXGRIDLibCtl.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(oGrid,Item,ColIndex,Key) RETURN |
<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.Grid.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 Grid1.Columns.Add("Editor").Editor .EditType = EditType .AddButton "Key1", 1 .AddButton "Key2", 2, EXGRIDLibCtl.AlignmentEnum.RightAlignment, "This is a bit of text that should be displayed when the cursor is over the button", "Some information" .AddButton "Key3", 3, EXGRIDLibCtl.AlignmentEnum.RightAlignment End With
...
Private Sub Grid1_ButtonClick(ByVal Item As EXGRIDLibCtl.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 '" & Grid1.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 Grid1_ButtonClick(ByVal Item As EXGRIDLibCtl.HITEM, ByVal ColIndex As Long, ByVal Key As Variant) With Grid1.Items Debug.Print .CellCaption(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 OnButtonClickGrid1(long Item, long ColIndex, const VARIANT FAR& Key) { CItems items = m_grid.GetItems(); CString strFormat; strFormat.Format( "%s, Key = '%s'", items.GetCellCaption( 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 AxGrid1_ButtonClick(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_ButtonClickEvent) Handles AxGrid1.ButtonClick With AxGrid1.Items Dim strKey As String = "" If Not (e.key Is Nothing) Then strKey = e.key.ToString() End If Debug.Print(.CellCaption(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 axGrid1_ButtonClick(object sender, AxEXGRIDLib._IGridEvents_ButtonClickEvent e) { string strKey = ""; if (e.key != null) strKey = e.key.ToString(); System.Diagnostics.Debug.WriteLine(axGrid1.Items.get_CellCaption(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.Grid1.Items .DefaultItem = item wait window nowait .CellCaption(0, colindex) endwith