jmj98

VB.net - How to set background color of a legend (programmatically in VB.NET) ?

Discussion created by jmj98 on Mar 20, 2011
I TESTED THIS CODE, BUT I SEE THAT I'M WRONG !!!

Someone has it scheduled this code (Arcgis 10) please?
The legend of the layout, it is transparent, but I like the opaque.

Thanks.

'............................................................

        elementUID.Value = "esriCarto.Legend"
        'The createsurroundframe method takes the UID of the element and an optional style.
        docMapSurroundFrame = docMapFrame.CreateSurroundFrame(elementUID, Nothing)
        docMapSurroundFrame.MapSurround.Name = ""

        Dim leg As ILegend
        leg = New ESRI.ArcGIS.Carto.Legend
        leg = docMapSurroundFrame.MapSurround
        If cmbCumple.Text.ToUpper = "LEGISLACI??N" Then
            leg.Title = RDLegislacion(cmbParametro.Text)
        Else
            leg.Title = "    VALORES UMBRAL - " & FechaI.Value.ToShortDateString & " - " & FechaF.Value.ToShortDateString
        End If
        Dim i As Integer
        For i = leg.ItemCount - 1 To 1 Step -1
            leg.RemoveItem(i)
        Next
       
        Dim pColor1 As IRgbColor
        pColor1 = New RgbColorClass
        pColor1.RGB = System.Drawing.ColorTranslator.ToWin32(Color.White)
        Dim pColor2 As IRgbColor
        pColor2 = New RgbColorClass
        pColor2.RGB = System.Drawing.ColorTranslator.ToWin32(Color.Black)
        Dim pSBack As ISymbolBackground
        pSBack = New SymbolBackgroundClass
        Dim pFillSym As IFillSymbol
        Dim pLinSym As ILineSymbol
        pFillSym = New SimpleFillSymbolClass
        pLinSym = New SimpleLineSymbol
        pFillSym.Color = pColor1
        pLinSym.Color = pColor2
        pFillSym.Outline = pLinSym
        pSBack.FillSymbol = pFillSym
        docMapSurroundFrame.Background = pSBack
        docMapSurroundFrame.MapSurround = leg

        'Now cast the MapSurroundFrame as an element so it can be inserted into the page layout.
        docMapFrame.Backcolor = System.Drawing.ColorTranslator.ToWin32(Color.White)
        docMapSurroundFrame.Border = docMapFrame.Border
        pSBack.FillSymbol.Color = pColor2
        docMapSurroundFrame.Background = docMapFrame.Background
        docElement = docMapSurroundFrame
        Dim MainMapElement As IElement
        Dim MainEnv As IEnvelope
        MainMapElement = docMapFrame
        MainEnv = MainMapElement.Geometry.Envelope
        Dim Env As IEnvelope
        Env = New Envelope
        Env.PutCoords(MainEnv.XMin + 0.3, MainEnv.YMin + 0.3, MainEnv.XMin + 6, MainEnv.YMin + 2.5)
        docElement.Geometry = Env

        docElement.Activate(docActiveView.ScreenDisplay)
        docGraphicsContainer.AddElement(docElement, 0)

'--------------------------------------------------------------

Outcomes