event ButtonClick (Node as Node, Key as Variant)
Occurs when user clicks on the cell's button.

 TypeDescription 
   Node as Node A Node object being clicked.  
   Key as Variant A Variant expression that indicates the key of the button inside the node being clicked.  
Use the ButtonClick event to notify your application that the user clicks a button inside a node. Use the AddButton method to add new buttons to an editor. Use the Editors property to access the control's Editors collection. Use the Add method to add new type of editors to the control. Use the Editor property to assign an editor to a node.

The following VB sample displays a message box when user clicks the 'A' button:

Private Sub Form_Load()
    With XMLGrid1
        .BeginUpdate
            With .Editors
                With .Add("Spin", SpinType)
                    .ButtonWidth = 18
                    .AddButton "A", 1
                End With
            End With
            With .Nodes
                With .Add("Spin", 1)
                    .Editor = "Spin"
                End With
            End With
        .EndUpdate
    End With
End Sub

Private Sub XMLGrid1_ButtonClick(ByVal Node As EXMLGRIDLibCtl.INode, ByVal Key As Variant)
    If Key = "A" Then
        MsgBox "You have clicked the 'A' button."
    End If
End Sub

The following C++ sample displays a message box when user clicks the 'A' button:

#include "Node.h"
void OnButtonClickXmlgrid1(LPDISPATCH Node, const VARIANT FAR& Key) 
{
	CNode node( Node ); node.m_bAutoRelease = FALSE;
	if ( V2S( &Key ) == "A" )
		MessageBox( "Click the button" ) ;
}

where the VS2 function converts a VARIANT expression to a string expression:

static CString V2S( const VARIANT* pvtValue )
{
	COleVariant vtString;
	vtString.ChangeType( VT_BSTR, (VARIANT*)pvtValue );
	return V_BSTR( &vtString );
}

The following VB.NET sample displays a message box when user clicks the 'A' button:

Private Sub AxXMLGrid1_ButtonClick(ByVal sender As Object, ByVal e As AxEXMLGRIDLib._IXMLGridEvents_ButtonClickEvent) Handles AxXMLGrid1.ButtonClick
    If e.key = "A" Then
        MsgBox("You have clicked the 'A' button.")
    End If
End Sub

The following C# sample displays a message box when user clicks the 'A' button:

private void axXMLGrid1_ButtonClick(object sender, AxEXMLGRIDLib._IXMLGridEvents_ButtonClickEvent e)
{
	if (e.key.ToString() == "A")
		MessageBox.Show("The user clicks the 'A' button. ");
}

The following VFP sample displays a message box when user clicks the 'A' button:

*** ActiveX Control Event ***
LPARAMETERS node, key

if ( key = "A" )
	wait window nowait "The uuser clicks the 'A' button. "
endif

 

 


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