Skip to main content
3 of 3
added 29 characters in body
Kelly Thomas
  • 1.5k
  • 1
  • 12
  • 24

Thanks Travis that did the trick.

The documentation ESRI provides for IDynamicLegendItem fails to list any CoClasses that implement, or methods that return this interface. This leaves it unclear how to access an an instance that provides an implementation of this interface.

After some trial and error I found the following technique works:

    Dim doc As IMxDocument = m_application.Document
    Dim map As IMap = doc.FocusMap

    Dim autoVisibility as Boolean= True

    Dim legend As Legend = Nothing

    For i As Integer = 0 To map.MapSurroundCount - 1
        If map.MapSurround(i).Name() = "Legend" Then
            legend = TryCast(map.MapSurround(i), Legend)
        End If
    Next

    If legend IsNot Nothing Then
        For i As Integer = 0 To legend.ItemCount - 1
            Dim item As IDynamicLegendItem = TryCast(legend.Item(i), IDynamicLegendItem)
            If item IsNot Nothing Then
                item.AutoVisibility = autoVisibility 
            End If
        Next
    End If
Kelly Thomas
  • 1.5k
  • 1
  • 12
  • 24