event DblClick (Shift as Integer, X as OLE_XPOS_PIXELS, Y as OLE_YPOS_PIXELS)

Occurs when the user dblclk the left mouse button over an object.

 TypeDescription 
   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 retrieve the column from cursor. Use the DateFromPoint property to specify the date from the cursor. Use the BarFromPoint property to get the bar from the point. Use the LinkFromPoint property to get the link from the point. Almost all properties that get an object from point supports -1,-1 coordinate that specifies the current cursor position, so no conversion is required for X and Y coordinates.

The following Access sample prints a message when an item has been double clicked:

Private Sub G2antt1_DblClick(ByVal Shift As Integer, ByVal X As Long, ByVal Y As Long)
    Dim h As HITEM
    Dim c As Long, hit As Long
    h = G2antt1.ItemFromPoint(-1, -1, c, hit)
    If Not (h = 0) Then
        MsgBox "The """ & G2antt1.Items.CellValue(h, c) & """ cell has been double clicked."
    End If
End Sub

The following VB sample prints a message when an item has been double clicked:

Private Sub G2antt1_DblClick(Shift As Integer, X As Single, Y As Single)
    ' 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 = G2antt1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Then
        MsgBox "The " & h & " item has been double clicked."
    End If
End Sub

The following VB sample displays a message when a cell has been double clicked:

Private Sub G2antt1_DblClick(Shift As Integer, X As Single, Y As Single)
    ' 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 = G2antt1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Then
        MsgBox "The """ & G2antt1.Items.CellValue(h, c) & """ cell has been double clicked."
    End If
End Sub

The following C++ sample displays the caption of the cell being double clicked ( including the inner cells ):

#include "Items.h"

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;
}

void OnDblClickG2antt1(short Shift, long X, long Y) 
{
	long c = NULL, hit = NULL;
	long h = m_g2antt.GetItemFromPoint( X, Y, &c, &hit );
	if ( ( h != 0 ) || ( c != 0 ) )
	{
		COleVariant vtItem( h ), vtColumn( c );
		CString strCaption = V2S( &m_g2antt.GetItems().GetCellValue( vtItem, vtColumn ) );
		MessageBox( strCaption );
	}
}

The following VB.NET sample displays the caption of the cell being double clicked ( including the inner cells ):

Private Sub AxG2antt1_DblClick(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_DblClickEvent) Handles AxG2antt1.DblClick
    Dim h As Integer, c As Integer, hit As EXG2ANTTLib.HitTestInfoEnum
    With AxG2antt1
        h = .get_ItemFromPoint(e.x, e.y, c, hit)
        If Not (h = 0) Or Not (c = 0) Then
            MessageBox.Show(.Items.CellValue(h, c))
        End If
    End With
End Sub

The following C# sample displays the caption of the cell being double clicked ( including the inner cells ):

private void axG2antt1_DblClick(object sender, AxEXG2ANTTLib._IG2anttEvents_DblClickEvent e)
{
	EXG2ANTTLib.HitTestInfoEnum hit;
	int c = 0, h = axG2antt1.get_ItemFromPoint( e.x, e.y, out c, out hit );
	if ( ( h != 0 ) || ( c != 0 ) )
		MessageBox.Show( axG2antt1.Items.get_CellValue( h, c ).ToString() );
}

The following VFP sample displays the caption of the cell being double clicked:

*** ActiveX Control Event ***
LPARAMETERS shift, x, y

local c, hit
c = 0
hit = 0

with thisform.G2antt1
	.Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit )
	if ( .Items.DefaultItem != 0 )
		wait window nowait .Items.CellValue( 0, c )
	endif
endwith



Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.