Type | Description | |||
Shift as Integer | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys. | |||
X as OLE_XPOS_PIXELS | A single that specifies the current X location of the mouse pointer. The x values is always expressed in container coordinates | |||
Y as OLE_YPOS_PIXELS | A single that specifies the current Y location of the mouse pointer. The y values is always expressed in container coordinates |
The DblClick event is fired when user double clicks the control. Use the ItemFromPoint method to determine the cell over the cursor. Use the ExpandOnDblClk property to specify whether an item is expanded or collapsed when user double clicks it. Use the ColumnFromPoint property to get the column from point.
Syntax for DblClick event, /NET version, on:
private void DblClick(object sender,short Shift,int X,int Y) { } Private Sub DblClick(ByVal sender As System.Object,ByVal Shift As Short,ByVal X As Integer,ByVal Y As Integer) Handles DblClick End Sub |
private void DblClick(object sender, AxEXGRIDLib._IGridEvents_DblClickEvent e) { } void OnDblClick(short Shift,long X,long Y) { } void __fastcall DblClick(TObject *Sender,short Shift,int X,int Y) { } procedure DblClick(ASender: TObject; Shift : Smallint;X : Integer;Y : Integer); begin end; procedure DblClick(sender: System.Object; e: AxEXGRIDLib._IGridEvents_DblClickEvent); begin end; begin event DblClick(integer Shift,long X,long Y) end event DblClick Private Sub DblClick(ByVal sender As System.Object, ByVal e As AxEXGRIDLib._IGridEvents_DblClickEvent) Handles DblClick End Sub Private Sub DblClick(Shift As Integer,X As Single,Y As Single) End Sub Private Sub DblClick(ByVal Shift As Integer,ByVal X As Long,ByVal Y As Long) End Sub LPARAMETERS Shift,X,Y PROCEDURE OnDblClick(oGrid,Shift,X,Y) RETURN |
<SCRIPT EVENT="DblClick(Shift,X,Y)" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function DblClick(Shift,X,Y) End Function </SCRIPT> Procedure OnComDblClick Short llShift OLE_XPOS_PIXELS llX OLE_YPOS_PIXELS llY Forward Send OnComDblClick llShift llX llY End_Procedure METHOD OCX_DblClick(Shift,X,Y) CLASS MainDialog RETURN NIL void onEvent_DblClick(int _Shift,int _X,int _Y) { } function DblClick as v (Shift as N,X as OLE::Exontrol.Grid.1::OLE_XPOS_PIXELS,Y as OLE::Exontrol.Grid.1::OLE_YPOS_PIXELS) end function function nativeObject_DblClick(Shift,X,Y) return |
The following VB sample displays a message when the user double clicks an item:
Private Sub Grid1_DblClick(Shift As Integer, X As Single, Y As Single) With Grid1 ' Converts the container coordinates to client coordinates X = X / Screen.TwipsPerPixelX Y = Y / Screen.TwipsPerPixelY Dim h As HITEM Dim c As Long, hit As Long ' Gets the item from (X,Y) h = .ItemFromPoint(X, Y, c, hit) If Not (h = 0) Or Not (c = 0) Then MsgBox "The '" & .Items.CellValue(h, c) & "' item has been double clicked." End If End With End Sub
The following VB sample use DblClick event to start editing control, if the AutoEdit property is False.
Private Sub Grid1_DblClick(Shift As Integer, X As Single, Y As Single) ' Starts the editing operation if the user dbl click in the control With Grid1 If (Not .AutoEdit) Then ' Did user dbl click on an item? Dim c As Long, hit as Long If Not (.ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit) = 0) Then .Edit End If End If End With End Sub
The following C++ sample displays the value of the cell being double clicked ( including the inner cells ):
#include "Items.h" void OnDblClickGrid1(short Shift, long X, long Y) { long c = NULL, hit = NULL; long h = m_grid.GetItemFromPoint( X, Y, &c, &hit ); if ( ( h != 0 ) || ( c != 0 ) ) { COleVariant vtItem( h ), vtColumn( c ); CString strCaption = V2S( &m_grid.GetItems().GetCellValue( vtItem, vtColumn ) ); MessageBox( strCaption ); } }
where the V2S function converts a VARIANT value to a string, and 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; }
The following VB.NET sample displays the value of the cell being double clicked ( including the inner cells ):
Private Sub AxGrid1_DblClick(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_DblClickEvent) Handles AxGrid1.DblClick Dim h As Integer, c As Integer, hit As EXGRIDLib.HitTestInfoEnum With AxGrid1 h = .get_ItemFromPoint(e.x, e.y, c, hit) If Not (h = 0) Or Not (c = 0) Then MessageBox.Show(.Items.CellCaption(h, c)) End If End With End Sub
The following C# sample displays the value of the cell being double clicked ( including the inner cells ):
private void axGrid1_DblClick(object sender, AxEXGRIDLib._IGridEvents_DblClickEvent e) { EXGRIDLib.HitTestInfoEnum hit; int c = 0, h = axGrid1.get_ItemFromPoint(e.x, e.y, out c, out hit); if ((h != 0) || (c != 0)) MessageBox.Show(axGrid1.Items.get_CellCaption(h, c).ToString()); }
The following VFP sample displays the value of the cell being double clicked:
*** ActiveX Control Event *** LPARAMETERS shift, x, y local c, hit c = 0 hit = 0 with thisform.Grid1 .Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit ) if ( .Items.DefaultItem != 0 ) wait window nowait .Items.CellCaption( 0, c ) endif endwith