Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to do a code to activate layers that are in a checkbox list, the code that I'm trying to use is this:

    MxDoc = My.ArcMap.Document
    Maps = MxDoc.Maps

    If chxActivated.SelectedItem = True Then
        GxLayer.Layer.Visible = True [COLOR="#FF0000"]HERE IS THE PROBLEM[/COLOR]
     End If

I add the layers with this code

    MxDoc = My.ArcMap.Document
    Map = MxDoc.FocusMap
    'new layer
    GxLayer = New GxLayer
    GxFile = GxLayer
    'Layer file path
    GxFile.Path = "C:\Layers\Aditional Information.lyr"
    'Add the new layer to ArcMap
    'Add the layer invisible
    GxLayer.Layer.Visible = False
    'Refresh the view
End Sub

Thank you!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've done just in case someone need it

 Dim i As Integer
           Dim SelectedIndex As Integer = chxActivated.SelectedIndex
    Dim chkstate As CheckState
    MxDoc = My.ArcMap.Document
    Maps = MxDoc.Maps
    Map = MxDoc.FocusMap
    PageLayout = MxDoc.PageLayout
    i = 0
    intMapCount = Maps.Count

    chkstate = chxActivated.GetItemCheckState(SelectedIndex)

    For i = 0 To chxActivated.Items.Count - 1
        If chkstate = CheckState.Checked Then
            Map.Layer(SelectedIndex).Visible = True
            Map.MapScale = 15000
            Map.Layer(SelectedIndex).Visible = False
        End If


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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