Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.