Venkat and Sherry,Thank you SO MUCH for your continued support on this it really has me confused.I've included my code below. I make the selection through an attribute query.Keep in mind the selection works just fine. The first time through the routineit selects and displays in the attribute window fine. However, if you try to makea second selection it will select but it won't display in the attribute window. I've tried partial and full refreshes and nothing helps. I don't know what elseto try.Greg
public static void SelectMyID(int MyID)
{
using (ComReleaser comReleaser = new ComReleaser())
try
{
MyMap.ClearSelection();
IFeatureWorkspace featworkspace = MyEditor3.EditWorkspace as IFeatureWorkspace;
IQueryFilter2 queryfilter2 = new QueryFilterClass();
queryfilter2.WhereClause = "ID = " + MyID;
IFeatureClass featClass = null;
ITable MyTable = featworkspace.OpenTable("MyTable");
ICursor cur = MyTable.Search(queryfilter2, false);
comReleaser.ManageLifetime(cur);
IRow row = null;
while ((row = cur.NextRow()) != null)
{
featClass = featworkspace.OpenFeatureClass(row.get_Value((int)row.Fields.FindField("MyTable")).ToString());
if (featClass != null)
{
switch (featClass.AliasName)
{
case "Feature1":
case "Feature2":
case "Feature3":
case "Feature4":
SelectFeature(featClass, (int)row.get_Value(row.Fields.FindField("ClassID")), 0, false, true);
break;
}
}
}
MyFindCommandAndExecute("{AB073B49-DE5E-11D1-AA80-00C04FA37860}", -1); //Zoom to selected
MyMxDoc.ActiveView.Refresh();
}
catch (Exception ex)
{
MyRecordError(ex);
}
}
public static void SelectFeature(IFeatureClass FC, int MyID, int AltID, bool ZoomTo, bool MultiSel)
{
try
{
if(!MultiSel)
MyMap.ClearSelection();
IFeatureSelection vFeatSel = GetCurrentLayer(FC.AliasName, 0) as IFeatureSelection;
if (vFeatSel == null)
return;
IQueryFilter2 queryfilt2 = new QueryFilterClass();
if (AltID > 0)
queryfilt2.WhereClause = "OtherID = " + AltID;
else
queryfilt2.WhereClause = "ClassID = " + MyID;
if(MultiSel)
vFeatSel.SelectFeaturesqueryfilt2, esriSelectionResultEnum.esriSelectionResultAdd, false);
else
vFeatSel.SelectFeatures(queryfilt2, esriSelectionResultEnum.esriSelectionResultNew, false);
vFeatSel.SelectionChanged();
if (ZoomTo)
FindCommandAndExecute("{AB073B49-DE5E-11D1-AA80-00C04FA37860}", -1);//esriArcMapUI.ZoomToSelectedCommand
}
catch (Exception ex)
{
MyRecordError(ex);
}
}
public static IFeatureLayer GetCurrentLayer(string sLayerName, int SubType)
{
try
{
ESRI.ArcGIS.esriSystem.UID pID = new ESRI.ArcGIS.esriSystem.UIDClass();
pID.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}";// IFeatureLayer
IMap myMap = myMxDoc.Activeview.FocusMap as IMap;
IEnumLayer pEnumLayer = MyMap.get_Layers(pID, true) as IEnumLayer;
pEnumLayer.Reset();
IFeatureLayer pFL;
while ((pFL = pEnumLayer.Next() as IFeatureLayer) != null)
{
if (pFL.FeatureClass.AliasName.ToLower() == sLayerName.ToLower())
{
return pFL;
}
}
}
catch (Exception ex)
{
MyRecordError(ex, "Layer Name = " + sLayerName);
}
return null;
}