public void AddTextElement(AxESRI.ArcGIS.Controls.AxMapControl map, IPoint point, string strText, string fontName, int size, double degree, short weight) { IGraphicsContainer pGraphicsContainer = map.ActiveView.GraphicsContainer; ITextElement pTextElement = new TextElementClass(); IElement pElement; IRgbColor pColor; IFontDisp pFont = new StdFontClass() as IFontDisp; pColor = new RgbColorClass(); pColor.Red = 0; pColor.Green = 0; pColor .Blue = 0; pFont.Name = fontName; pFont.Weight = weight; pFont.Size = size; IFormattedTextSymbol formatTextSyl = new TextSymbolClass(); formatTextSyl.Font = pFont; formatTextSyl.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; formatTextSyl.Angle = degree; pTextElement.Text = strText; pTextElement.Symbol = (ITextSymbol)formatTextSyl; pElement = (IElement)pTextElement; pElement.Geometry = (IGeometry)point; pGraphicsContainer.AddElement(pElement, 0); IActiveView activeView = map.ActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
Solved! Go to Solution.
You need to set ITextElement.ScaleText.
pTextElement.Text = strText; pTextElement.Symbol = (ITextSymbol)formatTextSyl;