anikameyer

Hide Legend in the TOC

Discussion created by anikameyer on May 15, 2012
Latest reply on May 17, 2012 by anikameyer
Dear all:

With the following code I would like to hide the legend in the TOC but it doesn't work. I wonder what I may do wrong. I am migrating my code from VBA (ArcGIS 9.2) to VB.Net in the Microsoft Visual Studio 2010 Programm.
I put you the new code. Perhaps you may help.
Thank you in advance.
Anika Meyer




            Dim pMXDoc As IMxDocument
            pMXDoc = My.ArcMap.Document

            Dim pMap As IMap
            pMap = pMXDoc.FocusMap

            Dim numLayer As Integer
            numLayer = pMap.LayerCount

            Dim pLayer As ILayer
            Dim pCadLayer As ICadDrawingLayers
            Dim pLegendInfo As ILegendInfo
            Dim pLegendGroup As ILegendGroup

            pLayer = pMap.Layer(1)

            pLayer.Visible = False
            If Not pLayer Is Nothing And (TypeOf pLayer Is ICadDrawingLayers) Then
                pCadLayer = pLayer
                pLegendInfo = pCadLayer
                pLegendGroup = New LegendGroup
                pLegendGroup = pLegendInfo.LegendGroup(0)
                pLegendGroup.Visible = False
                'Else
                'MsgBox("Layer not found or invalid: " & sname)
            End If

Outcomes