Fired when right mouse button is clicked.
Type | Description |
Use the RClick event to add your context menu. The RClick event notifies your application when the user right clicks the control. Use the Click event to notify your application that the user clicks the control ( using the left mouse button ). Use the MouseDown or MouseUp event if you require the cursor position during the RClick event. Use the RClickSelect property to specify whether the user can select items by right clicking the mouse. Use the ItemFromPoint property to get the item from point. Use the ColumnFromPoint property to get the column from point. Use the AllowOverviewZoom property to specify whether the control displays the zooming scale on the overview area, when the user right clicks the overview area.
Syntax for RClick event, /NET version, on:
private void RClick(object sender) { } Private Sub RClick(ByVal sender As System.Object) Handles RClick End Sub |
private void RClick(object sender, EventArgs e) { } void OnRClick() { } void __fastcall RClick(TObject *Sender) { } procedure RClick(ASender: TObject; ); begin end; procedure RClick(sender: System.Object; e: System.EventArgs); begin end; begin event RClick() end event RClick Private Sub RClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RClick End Sub Private Sub RClick() End Sub Private Sub RClick() End Sub LPARAMETERS nop PROCEDURE OnRClick(oG2antt) RETURN |
<SCRIPT EVENT="RClick()" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function RClick() End Function </SCRIPT> Procedure OnComRClick Forward Send OnComRClick End_Procedure METHOD OCX_RClick() CLASS MainDialog RETURN NIL void onEvent_RClick() { } function RClick as v () end function function nativeObject_RClick() return |
The following VB sample use Exontrol's ExPopupMenu Component to display a context menu when user has clicked the right mouse button in the control's client area:
Private Sub G2antt1_RClick() Dim i As Long i = PopupMenu1.ShowAtCursor End Sub
If you need to add a context menu based on the item you can use the MouseUp event, like in the following VB sample:
Private Sub G2antt1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button = 2) Then ' 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 Dim i As Long PopupMenu1.Items.Add G2antt1.Items.CellValue(h, c) i = PopupMenu1.ShowAtCursor End If End If End Sub
The following VC sample displays the caption of the cell where the mouse is released:
#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 OnMouseUpG2antt1(short Button, short Shift, long X, long Y) { long c = 0, hit = 0, hItem = m_g2antt.GetItemFromPoint( X, Y, &c, &hit ); if ( ( hItem != 0 ) || ( c != 0 ) ) { CItems items = m_g2antt.GetItems(); COleVariant vtItem( hItem ), vtColumn( c ); CString strCaption = V2S( &items.GetCellValue( vtItem, vtColumn ) ), strOutput; strOutput.Format( "Cell: '%s', Hit = %08X\n", strCaption, hit ); OutputDebugString( strOutput ); } }
The following VB.NET sample displays the caption of the cell where the mouse is released:
Private Sub AxG2antt1_MouseUpEvent(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_MouseUpEvent) Handles AxG2antt1.MouseUpEvent With AxG2antt1 Dim i As Integer, c As Integer, hit As EXG2ANTTLib.HitTestInfoEnum i = .get_ItemFromPoint(e.x, e.y, c, hit) If (Not (i = 0) Or Not (c = 0)) Then Debug.WriteLine("Cell: " & .Items.CellValue(i, c) & " Hit: " & hit.ToString()) End If End With End Sub
The following C# sample displays the caption of the cell where the mouse is released:
private void axG2antt1_MouseUpEvent(object sender, AxEXG2ANTTLib._IG2anttEvents_MouseUpEvent e) { int c = 0; EXG2ANTTLib.HitTestInfoEnum hit; int i = axG2antt1.get_ItemFromPoint( e.x, e.y, out c,out hit ); if ( ( i != 0 ) || ( c != 0 ) ) { string s = axG2antt1.Items.get_CellValue( i,c ).ToString(); s = "Cell: " + s + ", Hit: " + hit.ToString(); System.Diagnostics.Debug.WriteLine( s ); } }
The following VFP sample displays the caption of the cell where the mouse is released:
*** ActiveX Control Event *** LPARAMETERS button, shift, x, y local c, hit c = 0 hit = 0 with thisform.G2antt1 .Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit ) if ( .Items.DefaultItem <> 0 ) or ( c <> 0 ) wait window nowait .Items.CellValue( 0, c ) + " " + Str( hit ) endif endwith