6

ILayer.Visible seems to have no effect - How can I manually manage layer visibility and actually get the map control to update?

ILayer lyr = mapControl.get_Layer(i);

//this works for custom layers that I define but not for Bing_Maps.lyr or ESRI .lyr files that comes with ArcEngine or connections to ArcGIS Online. For composite layers, I also tried iterating through sub layers and setting the visibility to false

lyr.Visible = false;
mapControl.Update();
mapControl.Refresh();
mapControl.ActiveView.Refresh();
mapControl.Invalidate();
  • 2
    are you refreshing or partially refreshing the active view's display? By "manually" do you mean programmatically? – Kirk Kuykendall Jan 19 '11 at 1:01
  • Can you share your code? ILayer.Visible Property is the one which is used for this, & is working for me. – Devdatta Tengshe Jan 19 '11 at 3:48
  • edited code formatting – Petr Krebs Jan 19 '11 at 15:59
  • I added more code and a better description to answer your questions. I did see another post about ILayerFile and noticed that this interface has no visibility property - would it have anything to do with that? – Darren Jan 24 '11 at 21:35
  • I experienced problems with layer visibility while using the DynamicDisplay functionality. – patrick Jun 14 '11 at 16:36
2

If the layer is added to a basemap layer you need to Notify the baselayer that a layer has changed to ensure that it recreate it's display cache: Accessing a basemap sublayer

0

If you're using a ITOCControl, you can take a look at this featureITOCControl.LayerVisibilityEdit Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.