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();
Petr Krebs
  • 10,291
  • 1
  • 22
  • 33
Darren
  • 227
  • 1
  • 12

2 Answers2

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

MathiasWestin
  • 4,212
  • 2
  • 29
  • 48
0

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

Goldorak84
  • 1,274
  • 9
  • 27