Select to view content in your preferred language

How to set "Make newly added layers visible by default" in c#

1050
5
07-03-2012 10:57 AM
BradleyMontgomery
Emerging Contributor
I have inherited a C# application that opens ArcMap and does a lot of geoprocessing. The datasets are complex and cover a large area so they take a long time to draw. I'd like to programmatically uncheck the 'Make newly added layers visible by default' checkbox in the ArcMap Options window so that the application can run faster and wait to draw everything up after all the processing is done. I cannot find a reference anywhere to that setting. I have found the Igeoprocessoroptions interface that controls some similar options but not that one. Any ideas? Thanks.
0 Kudos
5 Replies
PeterYurkosky1
Regular Contributor
This is a registry setting. I found mine in HKEY_CURRENT_USER\Software\ESRI\Desktop10.1\ArcMap\Settings (it will be Desktop10.0 if that's what you're running). The value is named "LayerVisibility" and it needs to be set to 0 if you want newly added layers to be turned off. You'll need to use a standard .NET framework function to edit the registry.
0 Kudos
BradleyMontgomery
Emerging Contributor
Thanks! for getting back so fast. I was able to find that registry setting and that is a possible solution. However, this application is deployed through Citrix with multiple users on the same server. I'm hesitant to go hacking the registry in that environment for fear of causing problems for other users. I'm guessing that this particular setting is not exposed through ArcObjects since I'm not able to find any references to it anywhere. If that's the case, then the users will just have to learn to be patient while the process is running and those large data sets are drawing. I will check with the Citrix administrator about possible issues around making those kinds of registry changes.

Thanks again.
0 Kudos
KenBuja
MVP Esteemed Contributor
There's the IGeoProcessorSettings::AddOutputToMap property
0 Kudos
JamesCrandall
MVP Alum
Before any of the processing code runs, can you simply loop through the TOC and set each layer's visibility to false?  (not sure if it'd help, but it is fairly simple to implement this).  It'd be something like this:

(I just pulled this from another thread, you should fully test it on something simple first):

'also, you'd need to set your pDoc and pMap references before too!
Dim pLayer as IFeatureLayer
For intCount = 0 To pMap.LayerCount - 1 
   pLayer = pMap.Layer(intCount) 
   pLayer.Visible = False 
Next 
0 Kudos
BradleyMontgomery
Emerging Contributor
Thanks for that suggestion. The issue is new data that's created as a result of a geoprocessing operation. I can't control the visible property of that layer until it's been initially added to the MXD and therefore gets drawn up by default. Some of the layers are huge and very complex and take forever to draw. We want it to get added to the Table of contents of the MXD but not to get drawn so that the rest of the geoprocessing can proceed and the user can turn layers on/off as needed after it's all done.
0 Kudos