Sorry but we do not know how to fix this:
I pass the code that applies symbolization a layer of points with
ClassBreaksRenderer and "Quantities" and mode "Graduated Colors" from a .NET aplication, but at the end of the process, No way to update the table of contents.
If we use ArcMap, right click, properties on the layer and look at the symbolization form, ALL is perfect and if you click the OK button, all is well.
We refresh contents with
pMxDoc.UpdateContents()
and the activeView with
pMxDoc.ActiveView.Refresh()
Someone could tell us where we fail?
Code A is failing
--------------------------------
Dim pMxDoc As IMxDocument
Dim pLayer As ILayer
Dim pGeoLayer As IGeoFeatureLayer
Dim pFLayer As IFeatureLayer
Dim pFClass As IFeatureClass
Dim pRender As IClassBreaksRenderer
Dim pColor1 As IRgbColor
Dim pColor2 As IRgbColor
Dim pColor3 As IRgbColor
Dim i As Integer
'Dim pSFSym1 As ISimpleFillSymbol, pSFSym2 As ISimpleFillSymbol
Dim pSFSym1 As ISimpleMarkerSymbol, pSFSym2 As ISimpleMarkerSymbol
Dim pUIProperties As IClassBreaksUIProperties
Dim pRendererPropPage As IRendererPropertyPage
Dim pHistogram As IHistogram
Dim ptableHistogram As ITableHistogram
Dim pTable As ITable
Dim pClassify As IClassify
Dim classes() As Double
Dim dataValues() As Double, datafreq() As Integer
Dim pUIProp As IClassBreaksUIProperties
Dim fLR As IFeatureRenderer
Dim itemGal As IEnumStyleGalleryItem
Dim gallery As IStyleGallery
Dim gallery2 As IEnumStyleGalleryItem
Dim nom As String
Dim p1 As esriSimpleMarkerStyle
pMxDoc = m_pDoc
pLayer = pMxDoc.ActiveView.FocusMap.Layer(0)
pFLayer = pLayer
pFClass = pFLayer.FeatureClass
pTable = pFLayer
'ptableHistogram = New TableHistogram
'ptableHistogram.Field = "Valor"
'ptableHistogram.Table = pTable
'pHistogram = ptableHistogram
'pHistogram.GetHistogram(dataValues, datafreq)
'pClassify = New NaturalBreaks
'pClassify.SetHistogramData(dataValues, datafreq)
pRender = New ClassBreaksRenderer
pRender.Field = "Valor"
pRender.BreakCount = 2
pRender.MinimumBreak = 0
pRender.Break(0) = 249.9999
pRender.Break(1) = 5000
pUIProp = pRender
pUIProp.LowBreak(0) = 0
pUIProp.LowBreak(1) = 250
'pRender.Description(0) = "Cumple Legislación"
'pRender.Description(0) = "Incumple Legislación"
pRender.Label(0) = " < 250"
pRender.Label(1) = " >= 250"
pColor1 = New RgbColorClass
pColor1.RGB = System.Drawing.ColorTranslator.ToWin32(Color.Green Yellow)
pColor2 = New RgbColorClass
pColor2.RGB = System.Drawing.ColorTranslator.ToWin32(Color.Red)
pColor3 = New RgbColorClass
pColor3.RGB = System.Drawing.ColorTranslator.ToWin32(Color.Black )
Dim cc As IMarkerBackground
pSFSym1 = New SimpleMarkerSymbol
pSFSym1.Color = pColor1
pSFSym1.OutlineSize = 0.4
pSFSym1.OutlineColor = pColor3
pSFSym1.Size = 5
pSFSym1.Style = esriSimpleMarkerStyle.esriSMSSquare
pRender.Symbol(0) = pSFSym1
pSFSym2 = New SimpleMarkerSymbol
pSFSym2.Color = pColor2
pSFSym2.OutlineSize = 0.4
pSFSym2.OutlineColor = pColor3
pSFSym2.Size = 5
pSFSym2.Style = esriSimpleMarkerStyle.esriSMSCircle
pRender.Symbol(1) = pSFSym2
pRendererPropPage = New GraduatedColorPropertyPage
pGeoLayer = pFLayer
pGeoLayer.RendererPropertyPageClassID = pRendererPropPage.ClassID
pGeoLayer.Renderer = pRender
pGeoLayer.DisplayField = "Valor"
pGeoLayer.DisplayAnnotation = False
pMxDoc.ActiveView.PartialRefresh(esriViewDrawPhase .esriViewGeography, pLayer, Nothing)
pMxDoc.ActiveView.ContentsChanged()
pMxDoc.UpdateContents()
pMxDoc.ActiveView.Refresh()
---------------------------------------------------------------
Code B is running in VBA
-------------------------------------------------
Dim pMxDoc As IMxDocument
Dim pFLayer As IGeoFeatureLayer
Dim pFclass As IFeatureClass
Dim pFeature As IFeature
Dim pFCursor As IFeatureCursor
Dim pRender As IClassBreaksRenderer
Dim pTable As ITable
Dim pGeoLayer As IGeoFeatureLayer
Dim pColor1 As IRgbColor
Dim pColor2 As IRgbColor
Dim pColor3 As IRgbColor
Dim pUIProperties As IClassBreaksUIProperties
Set pMxDoc = Application.Document
Set pFLayer = pMxDoc.ActiveView.FocusMap.Layer(0)
Set pFclass = pFLayer.FeatureClass
Set pFCursor = pFclass.Search(Nothing, False)
Set pFeature = pFCursor.NextFeature
Set pTable = pFclass
Set pGeoLayer = pFLayer
Set pRender = New ClassBreaksRenderer
'Set pClassifyGEN = New Quantile
pRender.Field = "Valor"
pRender.BreakCount = 2
pRender.MinimumBreak = 0
pRender.Break(0) = 249.9999
pRender.Break(1) = 5000
Set pUIProperties = pRender
pUIProperties.LowBreak(0) = 0
pUIProperties.LowBreak(1) = 250
pRender.Label(0) = " < 250"
pRender.Label(1) = " > 250"
Set pColor1 = New RgbColor
Set pColor2 = New RgbColor
Set pColor3 = New RgbColor
pColor1.Red = 0
pColor1.Green = 255
pColor1.Blue = 0
pColor2.Red = 255
pColor2.Green = 0
pColor2.Blue = 0
pColor3.Red = 0
pColor3.Green = 0
pColor3.Blue = 0
Dim pSym1 As ISimpleMarkerSymbol
Set pSym1 = New SimpleMarkerSymbol
pSym1.Color = pColor1
pSym1.Outline = True
pSym1.OutlineSize = 0.4
pSym1.OutlineColor = pColor3
pSym1.Style = esriSMSCircle
pSym1.size = 5
pRender.Symbol(0) = pSym1
Dim pSym2 As ISimpleMarkerSymbol
Set pSym2 = New SimpleMarkerSymbol
pSym2.Color = pColor2
pSym2.Outline = True
pSym2.OutlineSize = 0.4
pSym2.OutlineColor = pColor3
pSym2.Style = esriSMSCircle
pSym2.size = 5
pRender.Symbol(1) = pSym2
' assign renderer to layer
Set pGeoLayer.Renderer = pRender
pMxDoc.UpdateContents
pMxDoc.ActiveView.Refresh
-------------------------------------------------
We use v9.2
Thanks in advance
Quim