Select to view content in your preferred language

FeatureDataGrid Selection Changed Event

2787
2
12-15-2011 08:01 AM
BrianGustafson
Occasional Contributor
I am trying to get attributes off of the last selected row but when I try to get that graphic in the selection changed event the graphics collection has not been updated yet.  How can I trigger an event when the SelectedGraphics collection changes.
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
You can use FeatureDataGrid.SelectionChanged event and iterate through e.AddedItems. To convert row to graphic, you can use the following method (add using System.Reflection).

private void MyDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
 foreach (var item in e.AddedItems)
 {
  var g = GetGraphicSibling(item);
 }
}

private static Graphic GetGraphicSibling(object item)
{
 if (item != null)
 {
  MethodInfo mi = item.GetType().GetMethod("GetGraphicSibling");
  if (mi != null)
   return mi.Invoke(item, null) as Graphic;
 }
 return null;
}
0 Kudos
BrianGustafson
Occasional Contributor
That gets me what I need.

Thanks.
0 Kudos