private void FrmCoordinateSystem_Load(object sender, EventArgs e) { switch (startPosition) { case "startFromMap": DirectoryInfo CoordDirInfo = new DirectoryInfo(ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Coordinate Systems"); LoadDirectories(advTreeCoord.Nodes[0], CoordDirInfo); richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pMapControl.SpatialReference); IEngineEditor pEngineEdit = new EngineEditorClass(); if (pEngineEdit.Map == pMapControl.Map) { advTreeCoord.Enabled = false; MessageBox.Show("该图层处在编辑状态不能修改坐标系统", "提示", MessageBoxButtons.YesNo); } break; case "startFromLayer": DirectoryInfo CoordDirInfoLayer = new DirectoryInfo(ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Coordinate Systems"); LoadDirectories(advTreeCoord.Nodes[0], CoordDirInfoLayer); IGeoDataset geoDataset = pLayer as IGeoDataset; ISpatialReference reference = geoDataset.SpatialReference; richTextReference.Text = ClsGDBDataCommon.GetReferenceString(reference); break; } }
private void 赋值ToolStripMenuItem_Click(object sender, EventArgs e) { LayerFrm lf = new LayerFrm(m_mapControl); lf.ShowDialog(); ILayer pLayer = lf.PLayer; IFeatureClass pFeatureClass = (pLayer as IFeatureLayer).FeatureClass; IDataset pDataset = pFeatureClass as IDataset; IEngineEditor pEngineEditor = new EngineEditorClass(); //开始编辑 pEngineEditor.StartEditing(pDataset.Workspace, axMapControl1.Map); //开始操作 pEngineEditor.StartOperation(); //设置目标图层 IEngineEditLayers pEditLayer = pEngineEditor as IEngineEditLayers; pEditLayer.SetTargetLayer(pLayer as IFeatureLayer, 0); //设置当前任务 pEngineEditor.CurrentTask = new Utilities.CalculatContourTask() as IEngineEditTask; //执行绘制操作 ICommand pSketch = new ControlsEditingSketchToolClass(); pSketch.OnCreate(axMapControl1.Object); //pSketch.OnClick(); axMapControl1.CurrentTool = pSketch as ITool; if (pEngineEditor.EditState == esriEngineEditState.esriEngineStateEditing) { pEngineEditor.StopEditing(true); } }
private void save_attribute() { //判断属性有没有改变 if (mDataGridTableChanged.Count == 0) { XtraMessageBox.Show("未进行修改", "提示信息", MessageBoxButtons.OK); return; } DataTable dt = dataGridView1.DataSource as DataTable; IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; //启动编辑 //todo //workspace maybe null IWorkspace workspace = pFeatureClass.FeatureDataset.Workspace; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); //mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mAxMapControl1.Map); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1); mEngineEditor.StartOperation(); UpdateFTOnDV(mLayer, dt, mDataGridTableChanged.ToArray <int>()); mEngineEditor.StopEditing(true); mDataGridTableChanged.Clear(); }
/// <summary> /// 在要素上面绘制一个可拖拽的符号 /// </summary> /// <param name="geometry"></param> public void DrawEditSymbol(IGeometry geometry, IDisplay display) { IEngineEditProperties engineProperty = new EngineEditorClass(); ISymbol pointSymbol = engineProperty.SketchVertexSymbol as ISymbol; ISymbol sketchSymbol = engineProperty.SketchSymbol as ISymbol; ITopologicalOperator pTopo = geometry as ITopologicalOperator; sketchSymbol.SetupDC(display.hDC, display.DisplayTransformation); sketchSymbol.Draw(pTopo.Boundary); IPointCollection pointCol = geometry as IPointCollection; for (int i = 0; i < pointCol.PointCount; i++) { IPoint point = pointCol.get_Point(i); pointSymbol.SetupDC(display.hDC, display.DisplayTransformation); pointSymbol.Draw(point); pointSymbol.ResetDC(); } //mMyMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, mMyselectedLayer, null); //----- //ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(sketchSymbol); //ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pointSymbol); //ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(engineProperty); }
public void DrawEditSymbol(IGeometry geometry, IDisplay display) { IEngineEditProperties engineProperty = new EngineEditorClass(); ISymbol pointSymbol = engineProperty.SketchVertexSymbol as ISymbol; ISymbol sketchSymbol = engineProperty.SketchSymbol as ISymbol; ITopologicalOperator pTopo = geometry as ITopologicalOperator; sketchSymbol.SetupDC(display.hDC, display.DisplayTransformation); sketchSymbol.Draw(pTopo.Boundary); IPointCollection pointCol = geometry as IPointCollection; for (int i = 0; i < pointCol.PointCount; i++) { IPoint point = pointCol.get_Point(i); pointSymbol.SetupDC(display.hDC, display.DisplayTransformation); pointSymbol.Draw(point); pointSymbol.ResetDC(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(sketchSymbol); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pointSymbol); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(engineProperty); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CmdCreateParrallel.OnClick implementation IEngineEditor pEngineEdit = new EngineEditorClass(); IEngineEditLayers pEEditLayers = pEngineEdit as IEngineEditLayers; IFeatureLayer targetLayer = pEEditLayers.TargetLayer; IFeatureSelection featureSelection = targetLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; if (selectionSet.Count > 0) { ICursor cursor; selectionSet.Search(null, true, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; IFeature feature = null; FrmParallelLineOffset frm = new FrmParallelLineOffset(); if (frm.ShowDialog() == DialogResult.OK) { while ((feature = featureCursor.NextFeature()) != null) { IPolyline pPolyline = ConstructOffset(feature.Shape as IPolyline, frm.offset); IFeature pFeature = targetLayer.FeatureClass.CreateFeature(); pFeature.Shape = pPolyline; pFeature.Store(); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } } } }
public static IFeatureLayer GetEditTargetLayer() { IEngineEditor pEngineEdit = new EngineEditorClass(); IEngineEditLayers pEEditLayers = pEngineEdit as IEngineEditLayers; IFeatureLayer targetLayer = pEEditLayers.TargetLayer; return(targetLayer); }
private void simpleButton1_Click(object sender, EventArgs e) { double offsetValue = -1; try { offsetValue = Convert.ToDouble(textEdit1.Text); } catch (Exception ex) { XtraMessageBox.Show("请输入数值类型", "提示信息", MessageBoxButtons.OK); return; } try { //启动编辑 IFeatureLayer featureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = featureLayer.FeatureClass; IWorkspace workspace = null; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); if (pFeatureClass.FeatureDataset != null) { workspace = pFeatureClass.FeatureDataset.Workspace; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1); mEngineEditor.StartOperation(); } ISelectionSet mSelectionSet = (mLayer as IFeatureSelection).SelectionSet; ICursor mCursor; mSelectionSet.Search(null, false, out mCursor); IFeature mFeature = mCursor.NextRow() as IFeature; while (mFeature != null) { IGeometry geometry = mFeature.ShapeCopy; IPolycurve polycurve = geometry as IPolycurve; polycurve.Smooth(offsetValue); mFeature.Shape = polycurve as IGeometry; mFeature.Store(); mFeature = mCursor.NextRow() as IFeature; } if (workspace != null) { mEngineEditor.StopEditing(true); } this.Dispose(); } catch (Exception ex) { XtraMessageBox.Show("平滑失败", "提示信息", MessageBoxButtons.OK); } }
private void initCurrentEditLayer() { EngineEditorClass eds = new EngineEditorClass(); ILayer L = eds.TargetLayer; if (L != null) { this.lab_CurrentEditLayer.Text = "当前编辑图层:" + L.Name; } else { this.lab_CurrentEditLayer.Text = "当前编辑图层:"; } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //check to see if there is an active edit session and whether edits have been made IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && engineEditor.HasEdits()) { DialogResult result = MessageBox.Show(@"Is save the edit?", @"Save the edit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show(@"Is save the current document?", @"Save document", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl //m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty; m_controlsSynchronizer.ReplaceMap(map); }
public override void OnClick() { //The snap editor form requires an edit session (e.g. in order to read the target layer and to set the snap tips) IEngineEditor editor = new EngineEditorClass(); if (editor.EditState != esriEngineEditState.esriEngineStateEditing) { System.Windows.Forms.MessageBox.Show("Please start an edit session"); return; } //Show the snap settings form if (snapEditor == null || snapEditor.IsDisposed) { snapEditor = new SnapEditor(); } snapEditor.Show(); snapEditor.BringToFront(); }
//开始编辑 private void Btn_Start_Click(object sender, EventArgs e) { try { string Layername = this.listBox2.Text; IFeatureLayer featLayer = this.zhmap.GetFeatureLayerByLayerName(Layername); if (featLayer != null) { EngineEditorClass engineEditSession = new EngineEditorClass(); engineEditSession.StartEditing((featLayer.FeatureClass as IDataset).Workspace, this.zhmap.Map); engineEditSession.SetTargetLayer(featLayer, 0); // initCurrentEditLayer(); } } catch (Exception ee) { MessageBox.Show(ee.Message, "提示"); } }
private void MapViewerForm_FormClosing(object sender, FormClosingEventArgs e) { try { IEngineEditor engineEditor = new EngineEditorClass(); if (engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) { CmdStopEdit cmdStopEdit = new CmdStopEdit(); cmdStopEdit.OnCreate(mainMapControl.Object); cmdStopEdit.OnClick(); if (cmdStopEdit.CancleFlag) { e.Cancel = true; } } mainMapControl.Map.ClearLayers(); } catch (Exception ex) { LogManager.GetLogger(GetType()).Error(ex); } }
protected override void OnClick() { // // TODO: Sample code showing how to access button host // ArcMap.Application.CurrentTool = null; // try { EngineEditorClass engineEditSession = new EngineEditorClass(); if (MessageBox.Show("是否要保存已修改的数据", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { engineEditSession.StopEditing(true); } else { engineEditSession.StopEditing(false); } } catch (Exception ee) { MessageBox.Show(ee.StackTrace, "提示"); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (getSetHookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)getSetHookHelper.Hook).Buddy; } //In case the container is MapControl else if (getSetHookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)getSetHookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(getSetHookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
public override void OnClick() { //The snap editor form requires an edit session (e.g. in order to read the target layer and to set the snap tips) IEngineEditor editor = new EngineEditorClass(); if (editor.EditState != esriEngineEditState.esriEngineStateEditing) { System.Windows.Forms.MessageBox.Show("Please start an edit session"); return; } //Show the snap settings form if (snapEditor == null || snapEditor.IsDisposed) { snapEditor = new SnapEditor(); } snapEditor.Show(); snapEditor.BringToFront(); }
private void button1_Click(object sender, EventArgs e) { try { string saveString = comboBox1.Text; // 属性过滤 IQueryFilter pQueryFilter = new QueryFilter(); if (pItems.Count > 0) { pQueryFilter.WhereClause = saveString; } else { pQueryFilter.WhereClause = null; } // 要素游标 //启动编辑 IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IWorkspace workspace = null; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); if (pFeatureClass.FeatureDataset != null) { workspace = pFeatureClass.FeatureDataset.Workspace; IMap mMap = mAxMapControl1.Map; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1); mEngineEditor.StartOperation(); } IFeatureCursor pFCursor = pFeatureClass.Search(pQueryFilter, false); IFeature pFeature = pFCursor.NextFeature(); //todo string str = getQueryString(); pFeature.Shape = GetMergeGeometry(str); pFeature.Store(); //pFCursor.Flush(); //删除语句 pItems.Remove(saveString); for (int i = 0; i < pItems.Count; i++) { delectSelectedCells(pItems[i]); } this.Close(); if (workspace != null) { mEngineEditor.StopEditing(true); } XtraMessageBox.Show("合并成功", "提示信息", MessageBoxButtons.OK); mAxMapControl1.Refresh(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "合并失败", MessageBoxButtons.OK); } }
/// <summary> /// �������� /// </summary> /// <param name="pSnapPnt"></param> /// <returns></returns> public bool SnapPoint(IPoint pSnapPnt) { IEngineSnapEnvironment pSnapEnv = new EngineEditorClass(); return pSnapEnv.SnapPoint(pSnapPnt); }
/// <summary> /// 捕捉到捕捉点 /// </summary> /// <param name="pSnapPnt"></param> /// <returns></returns> public bool SnapPoint(IPoint pSnapPnt) { IEngineSnapEnvironment pSnapEnv = new EngineEditorClass(); return(pSnapEnv.SnapPoint(pSnapPnt)); }
private void button1_Click(object sender, EventArgs e) { List <string> sqlWheres = GetSqlWhere(); if (sqlWheres == null) { return; } DialogResult result = DialogResult.OK; if (sqlWheres.Count == 0) { result = XtraMessageBox.Show("请选择要素", "提示信息", MessageBoxButtons.OKCancel); return; } result = XtraMessageBox.Show("确定删除吗?", "删除提示", MessageBoxButtons.OKCancel); if (result.ToString() != "OK") { return; } IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; //启动编辑 IFeatureDataset mFeatureDataset = pFeatureClass.FeatureDataset; IWorkspace workspace = null; if (mFeatureDataset == null) { workspace = pFeatureClass as Workspace; } else { workspace = pFeatureClass.FeatureDataset.Workspace; } IEngineEditor mEngineEditor = new EngineEditorClass(); if (workspace != null) { //mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeNonVersioned; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1); mEngineEditor.StartOperation(); } mAxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, mLayer, null); try { for (int i = 0; i < sqlWheres.Count; i++) { delectSelectedCells(sqlWheres[i], pFeatureClass); } if (workspace != null) { //保存编辑 mEngineEditor.StopEditing(true); } //删除属性表 deleteTableRows(sqlWheres); mAxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, mLayer, null); if (mAxMapControl2 != null) { mAxMapControl2.Refresh(); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DrawEditSymbol(IGeometry geometry, IDisplay display) { IEngineEditProperties engineProperty = new EngineEditorClass(); ISymbol pointSymbol = engineProperty.SketchVertexSymbol as ISymbol; ISymbol sketchSymbol = engineProperty.SketchSymbol as ISymbol; ITopologicalOperator pTopo = geometry as ITopologicalOperator; sketchSymbol.SetupDC(display.hDC, display.DisplayTransformation); sketchSymbol.Draw(pTopo.Boundary); IPointCollection pointCol = geometry as IPointCollection; for (int i = 0; i < pointCol.PointCount; i++) { IPoint point = pointCol.get_Point(i); pointSymbol.SetupDC(display.hDC, display.DisplayTransformation); pointSymbol.Draw(point); pointSymbol.ResetDC(); } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(sketchSymbol); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pointSymbol); ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(engineProperty); }
private bool MergeFeatures(int nFeatureID) { IEngineEditor pEngineEdit = new EngineEditorClass(); IEngineEditLayers pEEditLayers = pEngineEdit as IEngineEditLayers; IFeatureLayer targetLayer = pEEditLayers.TargetLayer; IFeatureClass featureClass = targetLayer.FeatureClass; IFeatureSelection featureSelection = targetLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; if (selectionSet.Count < 2) { return(false); } pEngineEdit.StartOperation(); try { object miss = Type.Missing; if (targetLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { return(false); } IFeature featureTarget = featureClass.GetFeature(nFeatureID); if (featureTarget == null) { return(false); } ITopologicalOperator top = featureTarget.ShapeCopy as ITopologicalOperator; int nID = -1; IEnumIDs enumIDs = selectionSet.IDs; enumIDs.Reset(); while ((nID = enumIDs.Next()) >= 0) { if (nID == nFeatureID) { continue; } IFeature feature = featureClass.GetFeature(nID); top = top.Union(feature.Shape) as ITopologicalOperator; } featureTarget.Shape = top as IGeometry; featureTarget.Store(); //删除其余要素 enumIDs.Reset(); while ((nID = enumIDs.Next()) >= 0) { if (nID == nFeatureID) { continue; } IFeature feature = featureClass.GetFeature(nID); feature.Delete(); } pEngineEdit.StopOperation("Merge features"); return(true); } catch (System.Exception ex) { pEngineEdit.AbortOperation(); } return(false); }
private void InitialGridTable() { superGridCtl.PrimaryGrid.ClearAll(); IEngineEditor pEngineEdit = new EngineEditorClass(); IEngineEditLayers pEEditLayers = pEngineEdit as IEngineEditLayers; IFeatureLayer targetLayer = pEEditLayers.TargetLayer; IFeatureSelection featureSelection = targetLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; if (selectionSet.Count > 0) { IFields fields = targetLayer.FeatureClass.Fields; IField field = null; //填充表格开头 for (int i = 0; i < fields.FieldCount; i++) { field = fields.get_Field(i); GridColumn col = new GridColumn(field.Name); col.Width = 100; superGridCtl.PrimaryGrid.Columns.Add(col); //记录OID字段索引 if (field.Type == esriFieldType.esriFieldTypeOID) { m_nIDFieldIndex = i; } } //读取要素属性 ICursor cursor; selectionSet.Search(null, true, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; IFeature feature = null; while ((feature = featureCursor.NextFeature()) != null) { object[] obj = new object[fields.FieldCount]; for (int i = 0; i < fields.FieldCount; i++) { field = fields.get_Field(i); if (field.Type == esriFieldType.esriFieldTypeGeometry) { obj[i] = field.Type.ToString(); } else { obj[i] = feature.get_Value(i); } } GridRow row = new GridRow(obj); superGridCtl.PrimaryGrid.Rows.Add(row); } //if (superGridCtl.PrimaryGrid.Rows.Count >0) //{ // GridRow row = (GridRow)superGridCtl.PrimaryGrid.GetRowFromIndex(0); // superGridCtl.PrimaryGrid.SetSelected(row, true); // superGridCtl.Refresh(); //} } }