event FormatColumn (ItemIndex as Long, ColIndex as Long, Value as Variant)
Fired when a cell requires to format its caption.

TypeDescription
ItemIndex as Long A long value that indicates the index of item being formatted. 
ColIndex as Long A long value that indicates the column's index. 
Value as Variant A VARIANT value that indicates the value that being displayed. Initially, the Value parameter indicates the the Caption value.

Use the FormatColumn event to display a string different than the Caption property. The FormatColumn event is fired only if the FireFormatColumn property of the Column is True. The FormatColumn event lets the user to provide the cell's caption before it is displayed on the control's list. For instance, the FormatColumn event is useful when the column cells contains prices( numbers ), and you want to display that column formatted as currency, like $150 instead 150. Also, using the FormatColumn event, you can display the result of some operations within an item, such of totals. Newer versions of the component provides the FormatColumn property that helps formatting a cell using the several predefined functions without using the control's event FormatColumn.

Syntax for FormatColumn event, /NET version, on:

private void FormatColumn(object sender,int ItemIndex,int ColIndex,ref object Value)
{
}

Private Sub FormatColumn(ByVal sender As System.Object,ByVal ItemIndex As Integer,ByVal ColIndex As Integer,ByRef Value As Object) Handles FormatColumn
End Sub

Syntax for FormatColumn event, /COM version, on:

private void FormatColumn(object sender, AxEXLISTLib._IListEvents_FormatColumnEvent e)
{
}

void OnFormatColumn(long ItemIndex,long ColIndex,VARIANT FAR* Value)
{
}

void __fastcall FormatColumn(TObject *Sender,long ItemIndex,long ColIndex,Variant * Value)
{
}

procedure FormatColumn(ASender: TObject; ItemIndex : Integer;ColIndex : Integer;var Value : OleVariant);
begin
end;

procedure FormatColumn(sender: System.Object; e: AxEXLISTLib._IListEvents_FormatColumnEvent);
begin
end;

begin event FormatColumn(long ItemIndex,long ColIndex,any Value)
end event FormatColumn

Private Sub FormatColumn(ByVal sender As System.Object, ByVal e As AxEXLISTLib._IListEvents_FormatColumnEvent) Handles FormatColumn
End Sub

Private Sub FormatColumn(ByVal ItemIndex As Long,ByVal ColIndex As Long,Value As Variant)
End Sub

Private Sub FormatColumn(ByVal ItemIndex As Long,ByVal ColIndex As Long,Value As Variant)
End Sub

LPARAMETERS ItemIndex,ColIndex,Value

PROCEDURE OnFormatColumn(oList,ItemIndex,ColIndex,Value)
RETURN

Syntax for FormatColumn event, /COM version (others), on:

<SCRIPT EVENT="FormatColumn(ItemIndex,ColIndex,Value)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function FormatColumn(ItemIndex,ColIndex,Value)
End Function
</SCRIPT>

Procedure OnComFormatColumn Integer llItemIndex Integer llColIndex Variant llValue
	Forward Send OnComFormatColumn llItemIndex llColIndex llValue
End_Procedure

METHOD OCX_FormatColumn(ItemIndex,ColIndex,Value) CLASS MainDialog
RETURN NIL

void onEvent_FormatColumn(int _ItemIndex,int _ColIndex,COMVariant /*variant*/ _Value)
{
}

function FormatColumn as v (ItemIndex as N,ColIndex as N,Value as A)
end function

function nativeObject_FormatColumn(ItemIndex,ColIndex,Value)
return

Before running any of the following samples, please make sure that the control contains more than 3 columns, and the third column has the FireFormatColumn property on True. The following VB sample displays the sum of the first two cells, and put the result on the third one: 

Private Sub List1_FormatColumn(ByVal ItemIndex As Long, ByVal ColIndex As Long, Value As Variant)
On Error Resume Next
    With List1.Items
        Value = Int(.Caption(ItemIndex, 0)) + Int(.Caption(ItemIndex, 1))
    End With
End Sub

The following VB sample displays long date format, using the FormatDateTime function:

Private Sub List1_FormatColumn(ByVal ItemIndex As Long, ByVal ColIndex As Long, Value As Variant)
On Error Resume Next
    Value = FormatDateTime(Value, vbLongDate)
End Sub

The following C++ sample displays the sum of the first two cells, and put the result on the third one: 

void OnFormatColumnList1(long ItemIndex, long ColIndex, VARIANT FAR* Value) 
{
	CItems items = m_list.GetItems();
	long newValue = V2I( &items.GetCaption( ItemIndex, COleVariant( long(0) ) ) );
	newValue += V2I( &items.GetCaption( ItemIndex, COleVariant( long(1) ) ) );
	V_VT( Value ) = VT_I4;
	V_I4( Value ) = newValue;
}

where the V2I function converts a VARIANT value to a long expression,

static long V2I( VARIANT* pv, long nDefault = 0 )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return nDefault;

		COleVariant vt;
		vt.ChangeType( VT_I4, pv );
		return V_I4( &vt );
	}
	return nDefault;
} 

The following C++ sample displays long date format:

void OnFormatColumnList1(long ItemIndex, long ColIndex, VARIANT FAR* Value) 
{
	COleDateTime date( *Value );
	COleVariant vtNewValue( date.Format( _T("%A, %B %d, %Y") ) );
	VariantCopy( Value, vtNewValue );
}

The following VB.NET sample displays the sum of the first two cells, and put the result on the third one: 

Private Sub AxList1_FormatColumn(ByVal sender As Object, ByVal e As AxEXLISTLib._IListEvents_FormatColumnEvent) Handles AxList1.FormatColumn
    With AxList1.Items
        Dim newValue As Integer = Integer.Parse(.Caption(e.itemIndex, 0), Globalization.NumberStyles.Any)
        newValue = newValue + Integer.Parse(.Caption(e.itemIndex, 1), Globalization.NumberStyles.Any)
        e.value = newValue
    End With
End Sub

The following VB.NET sample displays long date format:

Private Sub AxList1_FormatColumn(ByVal sender As Object, ByVal e As AxEXLISTLib._IListEvents_FormatColumnEvent) Handles AxList1.FormatColumn
    e.value = DateTime.Parse(e.value).ToLongDateString()
End Sub

The following C# sample displays the sum of the first two cells, and put the result on the third one: 

private void axList1_FormatColumn(object sender, AxEXLISTLib._IListEvents_FormatColumnEvent e)
{
	int newValue = int.Parse(axList1.Items.get_Caption(e.itemIndex, 0).ToString());
	newValue += int.Parse(axList1.Items.get_Caption(e.itemIndex, 1).ToString());
	e.value = newValue;
}

The following C# sample displays long date format:

private void axList1_FormatColumn(object sender, AxEXLISTLib._IListEvents_FormatColumnEvent e)
{
	e.value = DateTime.Parse(e.value.ToString()).ToLongDateString();
}

The following VFP sample displays the sum of the first two cells, and put the result on the third one:

*** ActiveX Control Event ***
LPARAMETERS itemindex, colindex, value

with thisform.List1.Items
	value = .Caption(itemindex,0) + .Caption(itemindex,1)
endwith