Setting Field in ArcMap Symbology Properties using ArcObjects?

المشرف العام

Administrator
طاقم الإدارة
I am programmatically rendering a feature layer in ArcMap but I can't set the Field property in the Symbology properties form. This results in the layer having the correct render/breaks/legend settings but the on screen render is wrong. When I open the Symbology tab the Field isn't set. When I do select the field the classification is reset. The focus field is actually from a linked table. Any suggestions? Below is the code I have for rendering the layer.

I'm using ArcGIS 10.2.2; Windows 7;VS2010 Express. Feature layer is in a file geodatabase along with a linked table.

I've asked this question on the ESRI forums with no solution yet so hopefully someone here can help.

public void ClassifyLayer(ref IFeatureLayer pFL, ITable pTable) {

IGeoFeatureLayer pGFLyr = (IGeoFeatureLayer)pFL; object dataValues; object dataFrequencies; ISimpleLineSymbol pLineFillSymbol; IClassBreaksUIProperties pClassBreaksUIProperties; IFeatureRenderer ifr = pGFLyr.Renderer; IClassBreaksRenderer pClassBreaksRenderer = (IClassBreaksRenderer)ifr; IDataSampling ds = (IDataSampling)pClassBreaksRenderer; ITableHistogram pTH = (ITableHistogram)new TableHistogram(); pTH.Field = "IDX"; pTH.Table = pTable; ds.MaxSampleSize = pTable.RowCount(null) + 1;; pTH.Sampling = ds; IHistogram pHist = (IHistogram)pTH; pHist.GetHistogram(out dataValues, out dataFrequencies); IClassify pClassify = new QuantileClass(); double[] classes; pClassify.SetHistogramData(dataValues, dataFrequencies); pClassify.Classify(10); classes = (double[])pClassify.ClassBreaks; pClassBreaksRenderer.BreakCount = classes.Length - 1; pClassBreaksRenderer.Field = pTH.Field; pClassBreaksRenderer.MinimumBreak = classes[0]; //Spectrum-Full Bright IMultiPartColorRamp pMultiColourRamp = GetSpectrumRamp(10); bool rampcreated = false; IEnumColors pColors = pMultiColourRamp.Colors; for (int i = 0; i < pClassBreaksRenderer.BreakCount; i++) { pLineFillSymbol = new SimpleLineSymbol(); pLineFillSymbol.Color = pColors.Next(); pClassBreaksRenderer.Symbol = (ISymbol)pLineFillSymbol; pClassBreaksRenderer.set_Break(i,classes[i + 1]); pClassBreaksRenderer.Label = ((Single)(classes)).ToString() + " - " + ((Single)(classes[i + 1])).ToString(); } pClassBreaksUIProperties = (IClassBreaksUIProperties)pClassBreaksRenderer; pClassBreaksUIProperties.Method = pClassify.ClassID; pClassBreaksUIProperties.ColorRamp = "Spectrum-Full Bright"; for (int i = 1; i < pClassBreaksRenderer.BreakCount; i++) { pClassBreaksUIProperties.set_LowBreak(i, pClassBreaksRenderer.Break[i - 1]); } pClassBreaksUIProperties.ShowClassGaps = true; pGFLyr.Renderer = (IFeatureRenderer)pClassBreaksRenderer; IRendererPropertyPage pRendererPropPage = (IRendererPropertyPage)new GraduatedColorPropertyPage(); pGFLyr.RendererPropertyPageClassID = pRendererPropPage.ClassID; pMxDoc.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFL, null); pMxDoc.UpdateContents();}

أكثر...
 
أعلى