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.
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(oTree) 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 Tree1_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 Tree1_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 = Tree1.ItemFromPoint(X, Y, c, hit) If Not (h = 0) Then Dim i As Long PopupMenu1.Items.Add Tree1.Items.CellCaption(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 OnMouseUpTree1(short Button, short Shift, long X, long Y) { long c = 0, hit = 0, hItem = m_tree.GetItemFromPoint( X, Y, &c, &hit ); if ( ( hItem != 0 ) || ( c != 0 ) ) { CItems items = m_tree.GetItems(); COleVariant vtItem( hItem ), vtColumn( c ); CString strCaption = V2S( &items.GetCellCaption( 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 AxTree1_MouseUpEvent(ByVal sender As Object, ByVal e As AxEXTREELib._ITreeEvents_MouseUpEvent) Handles AxTree1.MouseUpEvent With AxTree1 Dim i As Integer, c As Integer, hit As EXTREELib.HitTestInfoEnum i = .get_ItemFromPoint(e.x, e.y, c, hit) If (Not (i = 0) Or Not (c = 0)) Then Debug.WriteLine("Cell: " & .Items.CellCaption(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 axTree1_MouseUpEvent(object sender, AxEXTREELib._ITreeEvents_MouseUpEvent e) { int c = 0; EXTREELib.HitTestInfoEnum hit; int i = axTree1.get_ItemFromPoint( e.x, e.y, out c,out hit ); if ( ( i != 0 ) || ( c != 0 ) ) { string s = axTree1.Items.get_CellCaption( 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.Tree1 .Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit ) if ( .Items.DefaultItem <> 0 ) or ( c <> 0 ) wait window nowait .Items.CellCaption( 0, c ) + " " + Str( hit ) endif endwith