Take the 2-minute tour ×
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]
        MxDoc.UpdateContents()
        MxDoc.ActiveView.Refresh()
     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
    Map.AddLayer(GxLayer.Layer)
    'Add the layer invisible
    GxLayer.Layer.Visible = False
    'Refresh the view
    MxDoc.ActiveView.Refresh()
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
            MxDoc.ActiveView.Refresh()
        Else
            Map.Layer(SelectedIndex).Visible = False
            MxDoc.ActiveView.Refresh()
        End If
    Next

Cheers!

share|improve this answer

Your Answer

 
discard

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.