c# - Selecting a Graphic Element on button click using IGraphicContainerSelect -
c# - Selecting a Graphic Element on button click using IGraphicContainerSelect -
i having problem type casting , using right interfaces. have function loops through text elements specific property set. 1 time match found, want able select text element or create active or highlighted or whatever on map. code below.
protected override void onclick(item item) { imxdocument pdoc = validateinterface.getmxdocument(); iactiveview playout = (iactiveview)pdoc.pagelayout; igraphicscontainer pgraphicscont = (igraphicscontainer)pdoc.pagelayout; pgraphicscont.reset(); ielementproperties _elemprops = null; while ((_elemprops = (ielementproperties)pgraphicscont.next()) != null) { if (_elemprops.customproperty ipropertyset2) { itextelement _textelement = (itextelement)_elemprops; ipropertyset2 _propertyset = (ipropertyset2)_elemprops.customproperty; messagebox.show("before compare item string"); if (item.caption == convert.tostring(_propertyset.getproperty(name_string))) { //problems start here messagebox.show("inside if statement"); igraphicscontainerselect _selectmyelement = null; // = (igraphicscontainerselect)pgraphicscont; itextelement _newtextelement = (itextelement)pgraphicscont; ielement testelement = _newtextelement ielement; _selectmyelement.selectelement(testelement); } } }
}
nothing beingness selected though on map. i'm looping through each graphic element (igraphiccontainer) on map. 1 time find match, want select graphic element. trying utilize igraphiccontainerselect this. takes ielement variable type parameter, why i'm trying cast it. again, noting beingness selected. happens when click button.
any help on appreciated. in advance.
try refresh map. think improve way using playout.partialrefresh or pscreendisplay.invalidate methods.
playout.partialrefresh(esriviewdrawphase.esriviewgraphicselection,null,playout.extent)
or
iscreendisplay pscreendisplay = playout.screendisplay; pscreendisplay.invalidate(null,false,esriviewgraphicselection); pscreendisplay.updatewindow();
see help :http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000242000000
c# casting element containers arcobjects
Comments
Post a Comment