ESRI.ArcGIS.ADF.IMS
FindByName(String,Int32) Method
See Also  Example
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > LayerCollection Class > FindByName Method : FindByName(String,Int32) Method




name
Name of layer to find.
startIndex
Index of where in the collection to start looking.
Finds the first layer in the collection occurring after a given starting index.

Syntax

Visual Basic (Declaration) 
Public Overloads Function FindByName( _
   ByVal name As String, _
   ByVal startIndex As Integer _
) As Layer
Visual Basic (Usage)Copy Code
Dim instance As LayerCollection
Dim name As String
Dim startIndex As Integer
Dim value As Layer
 
value = instance.FindByName(name, startIndex)
C# 
public Layer FindByName( 
   string name,
   int startIndex
)

Parameters

name
Name of layer to find.
startIndex
Index of where in the collection to start looking.

Return Value

The first layer in the collection with a given name at or after the starting index, or null if no matching layer is found.

Example

The following example finds a layer by its name in the layer collection, starting at the third position in the collection. The code assumes an existing MapView object.
C#Copy Code
// Get the layer collection from a MapView 

ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection mapLayers = mapView.Layers; 

  

string layerName = "CITIES"; 

ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer foundLayer; 

foundLayer = mapLayers.FindByName(layerName, 2); 

  

if (foundLayer == null) 

    Label1.Text = "Layer " + layerName + " not found."; 

else 

    Label1.Text = "Layer " + layerName + ": ID is " + foundLayer.ID; 

    
Visual BasicCopy Code
' Get the layer collection from a MapView

Dim mapLayers As ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection

mapLayers = mapView.Layers



Dim layerName As String = "CITIES"

Dim foundLayer As ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer

foundLayer = mapLayers.FindByName(layerName, 2)



If IsNothing(foundLayer) Then

    Label1.Text = "Layer " + layerName + " not found."

Else

    Label1.Text = "Layer " + layerName + ": ID is " + foundLayer.ID

End If

Remarks

This finds a layer based on its Name property. Note that the Name of the layer need not be unique. If multiple layers share the same name, this method returns the first layer found with the name. The comparison is not case sensitive.

This overload of FindByName starts by examining the layer at the startIndex parameter in the layer collection, and searches toward the top (maximum index) layer.

See Also

© 2010 All Rights Reserved.