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();
-
2are you refreshing or partially refreshing the active view's display? By "manually" do you mean programmatically?Kirk Kuykendall– Kirk Kuykendall2011年01月19日 01:01:36 +00:00Commented Jan 19, 2011 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– Devdatta Tengshe2011年01月19日 03:48:57 +00:00Commented Jan 19, 2011 at 3:48
-
edited code formattingPetr Krebs– Petr Krebs2011年01月19日 15:59:54 +00:00Commented Jan 19, 2011 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– Darren2011年01月24日 21:35:06 +00:00Commented Jan 24, 2011 at 21:35
-
I experienced problems with layer visibility while using the DynamicDisplay functionality.patrick– patrick2011年06月14日 16:36:50 +00:00Commented Jun 14, 2011 at 16:36
2 Answers 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
If you're using a ITOCControl, you can take a look at this featureITOCControl.LayerVisibilityEdit Hope this helps