Determines whether the collection contains a specified MapItem.

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 bool Contains(
	MapItem item
)
Visual Basic (Declaration)
Public Function Contains ( _
	item As MapItem _
) As Boolean

Parameters

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

The MapItem to search for in the collection.

Return Value

trueTruetruetrue (True in Visual Basic) if the collection contains the specified MapItem; otherwise, falseFalsefalsefalse (False in Visual Basic).

Remarks

Use the Contains method to find out if a particular MapItem object is selected in the Contents window.

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