event SelectionChanged ()

Fired after a new item has been selected.

TypeDescription

Use the SelectionChanged event to notify your application that the user selects an item (that's selectable). Use the SelectableItem property to specify the user can select an item. The control supports single or multiple selection as well. When an item is selected or unselected the control fires the SelectionChanged event. Use the SingleSel property to specify if your control supports single or multiple selection. Use the SelectCount property to get the number of selected items. Use the SelectedItem property to get the selected item. Use the SelectItem to select or unselect a specified item. Use the FocusItem property to get the focused item. If the control supports only single selection, you can use the FocusItem property to get the selected/focused item because they are always the same. Use the SelForeColor and SelBackColor properties to specify colors for selected items. The AllowSelectObjects property allows users to select at runtime the bars and links in the chart area. Use the ItemBar(exBarSelected) property to select or unselect programmatically a bar. Use the Link(exLinkSelected) property to select or unselect programmatically a link. Use the SelectOnClick property to disable selecting new items when the user clicks the chart area.

Syntax for SelectionChanged event, /NET version, on:

private void SelectionChanged(object sender)
{
}

Private Sub SelectionChanged(ByVal sender As System.Object) Handles SelectionChanged
End Sub

Syntax for SelectionChanged event, /COM version, on:

private void SelectionChanged(object sender, EventArgs e)
{
}

void OnSelectionChanged()
{
}

void __fastcall SelectionChanged(TObject *Sender)
{
}

procedure SelectionChanged(ASender: TObject; );
begin
end;

procedure SelectionChanged(sender: System.Object; e: System.EventArgs);
begin
end;

begin event SelectionChanged()
end event SelectionChanged

Private Sub SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectionChanged
End Sub

Private Sub SelectionChanged()
End Sub

Private Sub SelectionChanged()
End Sub

LPARAMETERS nop

PROCEDURE OnSelectionChanged(oG2antt)
RETURN

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

<SCRIPT EVENT="SelectionChanged()" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function SelectionChanged()
End Function
</SCRIPT>

Procedure OnComSelectionChanged 
	Forward Send OnComSelectionChanged 
End_Procedure

METHOD OCX_SelectionChanged() CLASS MainDialog
RETURN NIL

void onEvent_SelectionChanged()
{
}

function SelectionChanged as v ()
end function

function nativeObject_SelectionChanged()
return

The following VB sample displays the selected items:

Private Sub G2antt1_SelectionChanged()
    On Error Resume Next
    Dim h As HITEM
    Dim i As Long, j As Long, nCols As Long, nSels As Long
    nCols = G2antt1.Columns.Count
    With G2antt1.Items
    nSels = .SelectCount
    For i = 0 To nSels - 1
        Dim s As String
        For j = 0 To nCols - 1
            s = s + .CellValue(.SelectedItem(i), j) + Chr(9)
        Next
    Debug.Print s
    Next
    End With
End Sub

The following VB sample expands programmatically items when the selection is changed:

Private Sub G2antt1_SelectionChanged()
    G2antt1.Items.ExpandItem(G2antt1.Items.SelectedItem()) = True
End Sub

The following VB sample displays the selected items:

Private Sub G2antt1_SelectionChanged()
    Dim i As Long
    With G2antt1.Items
        For i = 0 To .SelectCount - 1
            Debug.Print .CellValue(.SelectedItem(i), 0)
        Next
    End With
End Sub

The following VC sample displays the selected items:

#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 OnSelectionChangedG2antt1() 
{
	CItems items = m_g2antt.GetItems();
	for ( long i = 0; i < items.GetSelectCount(); i++ )
	{
		COleVariant vtItem( items.GetSelectedItem( i ) );
		CString strOutput;
		strOutput.Format( "%s\n", V2S( &items.GetCellValue( vtItem, COleVariant( (long)0 ) ) ) );
		OutputDebugString( strOutput );
	}
}

The following VB.NET sample displays the selected items:

Private Sub AxG2antt1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxG2antt1.SelectionChanged
    With AxG2antt1.Items
        Dim i As Integer
        For i = 0 To .SelectCount - 1
            Debug.WriteLine(.CellValue(.SelectedItem(i), 0))
        Next
    End With
End Sub

The following C# sample displays the selected items:

private void axG2antt1_SelectionChanged(object sender, System.EventArgs e)
{
	for ( int i = 0; i < axG2antt1.Items.SelectCount - 1; i++ )
	{
		object cell = axG2antt1.Items.get_CellValue( axG2antt1.Items.get_SelectedItem( i), 0 );
		System.Diagnostics.Debug.WriteLine( cell != null ? cell.ToString() : "" );
	}
}

The following VFP sample displays the selected items:

*** ActiveX Control Event ***

with thisform.G2antt1.Items
	for i = 0 to .SelectCount - 1
		.DefaultItem = .SelectedItem( i )
		wait window nowait .CellValue( 0, 0 )
	next
endwith