Select to view content in your preferred language

Change graphic color on select

679
1
03-22-2012 01:17 PM
Labels (1)
DanielLaidlaw
Deactivated User
I???m trying to highlight my selected graphic when a user clicks on it but I seem to get an error at the line graphicsContainer.updateElement(pElem), Does anyone happen to know what I might be doing wrong.

Appreciate the help.
Vik

      try
      {
       IEnumElement enumElement   = graphicsContainer.locateElements(point, LOCATE_ELEMENT_TOLARANCE);
       IElement pElem = null ;
       if (enumElement != null)
  {
        pElem = (IElement) enumElement.next();
        
        graphicsContainerSelect.selectElement(pElem);
   
             //Change the color of the selected graphic
   IRgbColor pColor = new RgbColor();
   pColor.setRGB(255); // red
   ISimpleFillSymbol pFillSym = new SimpleFillSymbol();
   pFillSym.setColor(pColor);
   pFillSym.setStyle(com.esri.arcgis.display.esriSimpleFillStyle.esriSFSSolid);
   IFillShapeElement fillShapeElement = null;
   fillShapeElement = new PolygonElement();
   fillShapeElement.setSymbol(pFillSym);
          pElem = (IElement) fillShapeElement;

                //Errors out here
                 graphicsContainer.updateElement(pElem);
      
        System.out.println("Graphic Selected");
     
     }
       System.out.println(" graphicsContainerSelect.getElementSelectionCount() " + graphicsContainerSelect.getElementSelectionCount());
       mxDocument.getActivatedView().partialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
      } catch ( Exception e ) { e.printStackTrace(); }
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
It seems your are using ArcObjects and not the WPF SDK.
You might get better answers by posting your question on this forum.
0 Kudos