event UserEditorOpen (Object as Object, Item as HITEM, ColIndex as Long)
Occurs when an user editor is about to be opened.

 TypeDescription 
   Object as Object An object created by UserEditor property  
   Item as HITEM A long expression that determines the item's handle. If the Item parameter is 0, and the ColIndex property is different than zero, the ColIndex indicates the handle of the cell where the state is changed.  
   ColIndex as Long A long expression that indicates the column's index, if the Item parameter is not zero, a long expression that indicates the handle of the cell if the Item parameter is 0.  

The control supports custom ActiveX editors support. The control fires the UserEditorOpen event when an user editor is shown. Use the UserEditorOpen event to initialize the user editor when it is shown. For instance, if you have a custom maskedit control you can initialize the mask and the value based on the cell's value property. Use the CellValue property to access the cell's value. The control fires the UserEditorOleEvent event each time when an user editor fires an event.  The control fires the UserEditorClose event when an user editor is  hidden.

The following VB sample selects an item into an user editor of EXCOMBOBOXLibCtl.ComboBox type ( the sample uses the Exontrol's ExComboBox Component ):

Private Sub G2antt1_UserEditorOpen(ByVal Object As Object, ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long)
   On Error Resume Next
    nEvents = nEvents + 1
    'Selects the value in the combo box
    With Object            ' Points to an EXCOMBOBOXLibCtl.ComboBox object 
        Dim sID As String
        sID = G2antt1.Items.CellValue(Item, ColIndex)
        If (G2antt1.Items.CellValueFormat(Item, ColIndex) = exHTML) Then
            sID = Mid(sID, 1, InStr(1, sID, " ", vbTextCompare) - 1)
        End If
        .Select(1) = sID
        If .Items.SelectCount > 0 Then
            .Items.EnsureVisibleItem .Items.SelectedItem(0)
        End If
    End With
    nEvents = nEvents - 1
End Sub

The following samples use the Exontrol's ExMaskEdit Component to mask floating point numbers using digit grouping.

The following VB sample initializes the mask's value when user editor is shown ( the sample calls the Text property of the exMaskEdit component ):

Private Sub G2antt1_UserEditorOpen(ByVal Object As Object, ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long)
    With G2antt1.Items
        Object.Text = .CellValue(Item, ColIndex)
    End With
End Sub

The following C++ sample initializes the mask's value when user editor is shown:

#import <maskedit.dll>

#include "Items.h"

void OnUserEditorOpenG2antt1(LPDISPATCH Object, long Item, long ColIndex) 
{
	MaskEditLib::IMaskEditPtr spMaskEdit( Object );
	if ( spMaskEdit != NULL )
	{
		CString strValue = V2S( &m_g2antt.GetItems().GetCellValue( COleVariant( Item ), COleVariant( ColIndex ) ) );
		spMaskEdit->PutText( strValue.AllocSysString() );
	}
}

where the #import <maskedit.dll> defines the type library of the exMaskEdit component, in the MaskEditLib namespace.  The V2S function converts a VARIANT value to a string value 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 initializes the mask's value when user editor is shown:

Private Sub AxG2antt1_UserEditorOpen(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_UserEditorOpenEvent) Handles AxG2antt1.UserEditorOpen
    With AxG2antt1.Items
        e.object.Text = .CellValue(e.item, e.colIndex)
    End With
End Sub

The following C# sample initializes the mask's value when user editor is shown:

private void axG2antt1_UserEditorOpen(object sender, AxEXG2ANTTLib._IG2anttEvents_UserEditorOpenEvent e)
{
	MaskEditLib.MaskEdit maskEdit = e.@object as MaskEditLib.MaskEdit;
	if (maskEdit != null)
	{
		object cellValue = axG2antt1.Items.get_CellValue(e.item, e.colIndex);
		maskEdit.Text = (cellValue != null ? cellValue.ToString() : "");
	}
}

where the MaskEditLib class is defined by adding a new reference to the ExMaskEdit component to your project.

The following VFP sample initializes the mask's value when user editor is shown:

*** ActiveX Control Event ***
LPARAMETERS object, item, colindex

with thisform.G2antt1.Items
	.DefaultItem = item
	object.Text = .CellValue( 0, colindex )
endwith



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