event StateChange (NewState as StatesEnum)
Fired when the list's state has been changed: focus, selection.

TypeDescription
NewState as StatesEnum A StatesEnum expression that represents the current state.

This event is fired each time current state is changed. The ViewFolderFlags property may be used to enable multiple items selection.

It is fired when one of the following operation occurs:

1. When eXShellView control got the focus,
2. When eXShellView lost the focus,
3. When current selection was changed,
4. When item was renamed.

Depending on newState variable, user can make certain actions. Use the Objects property to retrieve the collection of all or selected items.

The Objects.Get method gets:

Syntax for StateChange event, /NET version, on:

private void StateChange(object sender,exontrol.EXSHELLVIEWLib.StatesEnum NewState)
{
}

Private Sub StateChange(ByVal sender As System.Object,ByVal NewState As exontrol.EXSHELLVIEWLib.StatesEnum) Handles StateChange
End Sub

Syntax for StateChange event, /COM version, on:

private void StateChange(object sender, AxEXSHELLVIEWLib._IExShellViewEvents_StateChangeEvent e)
{
}

void OnStateChange(long NewState)
{
}

void __fastcall StateChange(TObject *Sender,Exshellviewlib_tlb::StatesEnum NewState)
{
}

procedure StateChange(ASender: TObject; NewState : StatesEnum);
begin
end;

procedure StateChange(sender: System.Object; e: AxEXSHELLVIEWLib._IExShellViewEvents_StateChangeEvent);
begin
end;

begin event StateChange(long NewState)
end event StateChange

Private Sub StateChange(ByVal sender As System.Object, ByVal e As AxEXSHELLVIEWLib._IExShellViewEvents_StateChangeEvent) Handles StateChange
End Sub

Private Sub StateChange(ByVal NewState As EXSHELLVIEWLibCtl.StatesEnum)
End Sub

Private Sub StateChange(ByVal NewState As Long)
End Sub

LPARAMETERS NewState

PROCEDURE OnStateChange(oExShellView,NewState)
RETURN

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

<SCRIPT EVENT="StateChange(NewState)" LANGUAGE="JScript">
</SCRIPT>

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

Procedure OnComStateChange OLEStatesEnum llNewState
	Forward Send OnComStateChange llNewState
End_Procedure

METHOD OCX_StateChange(NewState) CLASS MainDialog
RETURN NIL

void onEvent_StateChange(int _NewState)
{
}

function StateChange as v (NewState as OLE::Exontrol.ShellView.1::StatesEnum)
end function

function nativeObject_StateChange(NewState)
return

The following VB6 sample gets a collection of selected items ( in case your control allows multiple selection ):

Private Sub ExShellView1_StateChange(ByVal newState As EXSHELLVIEWLibCtl.StatesEnum)
    If (newState = SelChangeState) Then
        ExShellView1.Objects.Get SelectedItems
        With ExShellView1.Objects
            For i = 0 To .Count - 1
                Debug.Print .Item(i).Name
            Next
        End With
    End If
End Sub

In case your control supports single selection, you can use the ObjectSelected event to notify when a new item/object is selected:

Private Sub ExShellView1_ObjectSelected(ByVal Object As EXSHELLVIEWLibCtl.IExShellObject)
    If Not (Object Is Nothing) Then
        Debug.Print Object.Name
    End If
End Sub

The following VB.NET sample shows how to get the selected files/folder for /NET assembly version:

Dim i As Long = 0, s As String = ""
With Exshellview1
    .Objects.Get(exontrol.EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems)
    With .Objects
        For i = 0 To .Count - 1
            Dim sel As exontrol.EXSHELLVIEWLib.exshellobject = .Item(i)
            ' * The sel indicates the shell object being selected *
            s = s + sel.Name + vbCrLf
        Next
    End With
End With
If s.Length > 0 Then
    MessageBox.Show(s, "Selection")
Else
    MessageBox.Show("Empty", "Selection")
End If

The following C# sample shows how to get the selected files/folder for /NET assembly version:

string s = "";
exshellview1.Objects.Get(exontrol.EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems);
for ( int i = 0; i < exshellview1.Objects.Count; i++ )
{
    exontrol.EXSHELLVIEWLib.exshellobject sel = exshellview1.Objects[i];
    // * The sel indicates the shell object being selected *
    s = s + sel.Name + "\r\n";
}
if (s.Length > 0)
    MessageBox.Show(s, "Selection");
else
    MessageBox.Show("Empty", "Selection");

The following VB.NET sample shows how to get the selected files/folder for /COM on Window.Forms  version:

Dim i As Long = 0, s As String = ""
With AxExShellView1
    .Objects.Get(EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems)
    With .Objects
        For i = 0 To .Count - 1
            Dim sel As EXSHELLVIEWLib.ExShellObject = .Item(i)
            ' * The sel indicates the shell object being selected *
            s = s + sel.Name + vbCrLf
        Next
    End With
End With
If s.Length > 0 Then
    MessageBox.Show(s, "Selection")
Else
    MessageBox.Show("Empty", "Selection")
End If

The following C# sample shows how to get the selected files/folder for /COM on Window.Forms  version:

string s = "";
axExShellView1.Objects.Get(EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems);
for (int i = 0; i < axExShellView1.Objects.Count; i++)
{
    EXSHELLVIEWLib.ExShellObject sel = axExShellView1.Objects[i];
    // * The sel indicates the shell object being selected *
    s = s + sel.Name + "\r\n";
}
if (s.Length > 0)
    MessageBox.Show(s, "Selection");
else
    MessageBox.Show("Empty", "Selection");

The following VB6  sample shows how to get the selected files/folder for /COM version:

Dim i As Long, s As String
s = ""
With ExShellView1
    .Objects.Get (EXSHELLVIEWLibCtl.ObjectTypeEnum.SelectedItems)
    With .Objects
        For i = 0 To .Count - 1
            Dim sel As EXSHELLVIEWLibCtl.ExShellObject
            Set sel = .Item(i)
            ' * The sel indicates the shell object being selected *
            s = s + sel.Name + vbCrLf
        Next
    End With
End With
If Len(s) > 0 Then
    MsgBox s, , "Selection"
Else
    MsgBox "Empty", , "Selection"
End If

The following Access sample shows how to get the selected files/folder for /COM version:

Dim i As Long, s As String
s = ""
With ExShellView1
    .Objects.Get (EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems)
    With .Objects
        For i = 0 To .Count - 1
            Dim sel As EXSHELLVIEWLib.ExShellObject
            Set sel = .Item(i)
            ' * The sel indicates the shell object being selected *
            s = s + sel.Name + vbCrLf
        Next
    End With
End With
If Len(s) > 0 Then
    MsgBox s, , "Selection"
Else
    MsgBox "Empty", , "Selection"
End If

The following VPF sample shows how to get the selected files/folder for /COM version:

local sel
s = ""
with thisform.ExShellView1
	.Objects.Get(1)
	for i = 0 to .Objects.Count - 1
		sel = .Objects.Item(i)
		s = s + sel.Name + chr(13)+chr(10)
	next	
endwith
messagebox(s)

The following C++ sample shows how to get the selected files/folder for /COM version:

CString s;
CExShellObjects objects = m_shellView.GetObjects();
objects.Get( 1 );
for ( long i = 0; i < objects.GetCount(); i++ )
{
	CExShellObject sel = objects.GetItem( COleVariant( i ) );
	s = s + sel.GetName() + _T("\r\n");

}
if ( s.GetLength() > 0 )
	MessageBox( s, _T("Selection") );
else
	MessageBox( _T("Empty"), _T("Selection") );