This document is archived and information here might be outdated.  Recommended version.


IEditor.EditSelection Property (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Editor)  

IEditor.EditSelection Property

The selected features which are editable.

[Visual Basic .NET]
Public ReadOnly Property EditSelection As IEnumFeature
[C#]
public IEnumFeature EditSelection {get;}

Product Availability

Available with ArcGIS Desktop.

Description

public void GetMapSelection()
{  
  //Get a reference to IApplication app in ICommand::OnCreate hook parameter.
  IEditor sEditor=app.FindExtensionByName("ESRI Object Editor") as IEditor;
  IEnumFeature enumFeature=sEditor.EditSelection;
  enumFeature.Reset();
  IFeature selFeature=enumFeature.Next();
  for (int fCount=0; fCount < sEditor.SelectionCount; fCount++)
  { 
    IGeometry selGeometry=selFeature.Shape;
    'Put code here to do something with the geometry
     System.Windows.Forms.MessageBox.Show(selGeometry.GeometryType);
     selFeature=enumFeature.Next;
  }
}

Remarks

This property returns all of the currently selected features that belong to editable layers. Use this property when creating an editing tool or command that works with the current selection.
[C#]
public void GetMapSelection()
{
    //get editor extension
    UID editorUID=new UID();
    editorUID.Value="esriEditor.Editor";
    IEditor editor=m_application.FindExtensionByCLSID(editorUID) as IEditor;
    IEnumFeature selectedFeatures=editor.EditSelection as IEnumFeature;
    selectedFeatures.Reset();
    IFeature currentFeature=selectedFeatures.Next();
    while(currentFeature != null)
    {
        IGeometry geometry=currentFeature.Shape;
        //Code to do something with the geometry
        //In this example we'll msgbox the geometry type
        System.Windows.Forms.MessageBox.Show(geometry.GeometryType.ToString());
        currentFeature=selectedFeatures.Next();
    }
}
[Visual Basic .NET]
Private sub GetEditSel() 'Get Iapplication from
  ICommand::OnCreate hook parameter. 
Dim geometry as IGeometry
Dim enumFeature As IEnumFeature
Dim feature as IFeature
Dim fieldCount As Integer

'Get an object reference to IEditor. 
Dim  editorUID As UID=New UIDClass()
 editorUID.Value= "esriEditor.Editor"
  Dim editor As IEditor=app.FindExtensionByCLSID(editorUID) 
  editor.StartOperation()
  enumFeature=editor.EditSelection
enumFeature.Reset() 
feature=enumFeature.Next 
If feature Is Nothing
Then m_Editor.AbortOperation() 
   Exit Sub 
 End If
 For fieldCount=0 To editor.SelectionCount - 1 
 origPartGeometry=enumFeature.Shape 

   'Code to do something with the geometry. 'In this example we'll messagebox the geometry type
   MessageBox.Show(origPartGeometry.GeometryType) 
origFeature=enumFeature.Next
Next fieldCount
End Sub

 

See Also

IEditor Interface

.NET Snippets

Flip Line Direction

.NET Samples

Curve conversion add-in (Code Files: CurveConversionDockWin)