Selects the specified MapItem in the Contents window, and unselects all other MapItems.

Namespace:  ESRI.ArcGISExplorer.Application

Assembly:  ESRI.ArcGISExplorer.Application (in ESRI.ArcGISExplorer.Application.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public void Select(
	MapItem item
)
Visual Basic (Declaration)
Public Sub Select ( _
	item As MapItem _
)

Parameters

item
Type: ESRI.ArcGISExplorer.Mapping..::.MapItem

The MapItem to select.

Remarks

This method allows programmatic selection of an item in the Contents window. Calling this method will unselect all other items.

When the selection is changed, the MapItemSelectionChanged is triggered.

Examples

The code below uses the FindByName method on the Map class to find a MapItem with a specific name, and then uses the SelectedItems property on the Application class, and the Contains method on the SelectedItemsCollection class to identify if the MapItem is currently selected in the Contents window of the application. If the MapItem is found in the Contents but is not selected, it is then programmatically selected using the Select method. Message boxes indicate the results or actions taken.
CopyC#
string itemNameToFind = "Cities";
ESRI.ArcGISExplorer.Mapping.MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
MapItem itm = disp.Map.FindByName(itemNameToFind); // Find by name is case-insensitive and returns the first encountered match.
if (itm != null)
{
  // Use SelectedItems.Contains to find out if a specific MapItem is selected in the Contents window.
  ESRI.ArcGISExplorer.Application.SelectedItemsCollection selItems = ESRI.ArcGISExplorer.Application.Application.SelectedItems;
  if (selItems.Contains(itm))
  {
    MessageBox.Show(itm.Name + " is already selected in the Contents window");
  }
  else
  {
    selItems.Select(itm);
    MessageBox.Show(itm.Name + " has been programmatically selected in the Contents window");
  }
}
else
{
  MessageBox.Show("Could not find a MapItem with the name " + itemNameToFind);
}
CopyVB.NET
Dim itemNameToFind As String = "Cities"
Dim disp As ESRI.ArcGISExplorer.Mapping.MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
Dim itm As MapItem = disp.Map.FindByName(itemNameToFind) ' Find by name is case-insensitive and returns the first encountered match.
If Not itm Is Nothing Then
  ' Use SelectedItems.Contains to find out if a specific MapItem is selected in the Contents window.
  Dim selItems As ESRI.ArcGISExplorer.Application.SelectedItemsCollection = ESRI.ArcGISExplorer.Application.Application.SelectedItems
  If selItems.Contains(itm) Then
    MessageBox.Show(itm.Name & " is already selected in the Contents window")
  Else
    selItems.Select(itm)
    MessageBox.Show(itm.Name & " has been programmatically selected in the Contents window")
  End If
Else
  MessageBox.Show("Could not find a MapItem with the name " & itemNameToFind)
End If

See Also