arcengine C# 布局插入文本
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Analyst3D;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.GeoAnalyst;
using stdole;
public void AddTextElement(AxPageLayoutControl PageLayoutControl, double x, double y, string textName)
{
IPageLayout pPageLayout;
IActiveView pAV;
IGraphicsContainer pGraphicsContainer;
IPoint pPoint;
ITextElement pTextElement;
IElement pElement;
ITextSymbol pTextSymbol;
IRgbColor pColor;
pPageLayout = PageLayoutControl.PageLayout;
pAV = (IActiveView)pPageLayout;
pGraphicsContainer = (IGraphicsContainer)pPageLayout;
pTextElement = new TextElementClass();
IFontDisp pFont = new StdFontClass() as IFontDisp;
pFont.Bold = true;
pFont.Name = "宋体";
pFont.Size = 20;
pColor = new RgbColorClass();
pColor.Red = 255;
pTextSymbol = new TextSymbolClass();
pTextSymbol.Color = (IColor)pColor;
pTextSymbol.Font = pFont;
pTextElement.Text = textName;
pTextElement.Symbol = pTextSymbol;
pPoint = new PointClass();
pPoint.X = x;
pPoint.Y = y;
pElement = (IElement)pTextElement;
pElement.Geometry = (IGeometry)pPoint;
pGraphicsContainer.AddElement(pElement, 0);
pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
private void button2_Click_1(object sender, EventArgs e)
{
AddTextElement(this.axPageLayoutControl1, 10, 10, "gisoracle欢迎你 Email:gisoracle@126.com,或QQ:276529800联系");
}
参考:http://www.gisbase.cn/chxnews.asp?id=1019