AnsweredAssumed Answered

Programmatically add selected feature to editSelection

Question asked by rennerken on Aug 7, 2014
Latest reply on Aug 8, 2014 by rennerken

I have created a button that creates a feature at a current GPS location.

I can create the feature easy enough and set it as selected.

Immediately after it is created I want it to be added to the Edit Selection so the user doesn't have to manually use the editor tool to select it.

Thanks for any help you can give me.

                           //Start Edit Session

                            UID uid = new UIDClass();

                            uid.Value = "esriEditor.Editor";

                            IEditor editor = cls_globals.M_IAPPLICATION.FindExtensionByCLSID(uid) as IEditor;                           

                            editor.StartOperation();

                            IFeatureClass pfcl = cls_globals.GetIFeatureClass(cls_globals.CURRENT_POLE_LAYER);

                            IFeature ftr = pfcl.CreateFeature();

                            ftr.Shape = cls_globals.CURRENT_GPS_POINT_GEOMETRY;

 

                            ILayer lyr = (ILayer)cls_globals.GetFeatureLayer(cls_globals.CURRENT_POLE_LAYER);

                            IEditTemplate editTemplate = GetEditTemplate(lyr);

                            editTemplate.SetDefaultValues(ftr);                          

                            ftr.Store();                         

                            editor.Display.Invalidate(ftr.Extent, true, (short)esriScreenCache.esriAllScreenCaches);

                            IFeatureSelection pfsel = (IFeatureSelection)cls_globals.GetFeatureLayer(cls_globals.CURRENT_POLE_LAYER);

                            pfsel.Add(ftr);

                            //At this point I have the feature created and selected.

                            editor.SelectionAnchor.MoveTo((IPoint)ftr.Shape, editor.Display);

                            editor.SelectionAnchor.Draw(editor.Display);                                                                      

                            editor.StopOperation("Create Pole at Current GPS Location");

                            //This is where I want it added to the editor.EditSelection so the user can immediately 

                            //start editing the attributes in the editor attribute window.

                            cls_globals.CURRENT_MXDOC.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

Outcomes