changing properties of layer files programatically

510
3
05-03-2010 08:52 AM
DavidKelly1
New Contributor
Does anyone have sample code showing how to programatically change the properties of a layer file?  I am using ArcGIS 9.2.

David Kelly
0 Kudos
3 Replies
JohnHauck
Occasional Contributor II
Specifically what properties, for what type of layer? Here are a couple of the interfaces that may be used for a standard feature layer:

http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriCarto/ILayer.htm

http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriCarto/IFeatureLayer2.htm


A simple example may be:

Public Sub SimpleTest()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    
    Dim pFL As IFeatureLayer
    Set pFL = pMxDoc.FocusMap.Layer(0)
    
    pFL.Name = "new name"
    pFL.Visible = False
    
    pMxDoc.ActiveView.Refresh
    pMxDoc.UpdateContents
End Sub
0 Kudos
DavidKelly1
New Contributor
I guess I was not clear in my original post.  I would like to be able to change the properties of a .lyr file.  It seems like I should be able to read and change the properties of a lyr file.

Thanks for your help.

David Kelly
0 Kudos
NeilClemmons
Regular Contributor III
A layer file doesn't have any properties for you to change.  The process would be to open the layer file, get the layer it contains, change that layer however you need to, replace the layer in the layer file with your updated layer, then save the layer file back out.  You can use ILayerFile to access the layer file on disk.
0 Kudos