I have a legend which I am attempting to use in an automated mapping application however I am getting strange results. I am attempting to set the default patch size but it (seemingly randomly) changes the patch and font size (not sure if its important but the mapsurroundframe is resized too although I think this is supposed to resize automatically with changes in the legend contents) even though the same code is ran each time.
For example, see the 2 attached pictures, one is *close* to the patch size I have asked for and the other is way off, and this is all from running the same code (below) over and over. Sometimes when I run it it will not appear to do anything then randomely it resizes everything.
Can anyone please tell me how I can fix this?
Thanks heaps in advance, this is driving me crazy!!!
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Get legend Dim pMapSurroundFrame As IMapSurroundFrame = GetMapElement("emtLegend") Dim pSurround As IMapSurround = pMapSurroundFrame.MapSurround Dim pLegend As ILegend = pSurround
With pLegend .Format.DefaultPatchWidth = 19.845 .Format.DefaultPatchHeight = 8.505 .Format.LayerNameGap = 1 .Format.VerticalItemGap = 1 .Format.ShowTitle = False End With
RefreshLegend(GetMapElement("emtLegend")) End Sub
Sub RefreshLegend(ByRef pElement As IElement)
' Refresh the legend. Dim pMSF As IMapSurroundFrame = pElement Dim pMapSurround As IMapSurround = pMSF.MapSurround Dim pEnv = New Envelope Dim pLegend As ILegend = pMapSurround