AO 获取系统自带的工具条

备忘给自己看.

如何调用系统自带的Editor编辑工具条,并打开Editor工具条。

代码如下:ICommandBars commandBars = m_application.Document.CommandBars;

UID barID = new ESRI.ArcGIS.esriSystem.UIDClass();
barID.Value = "esriEditor.EditorToolBar";// Example: "esriArcMapUI.StandardToolBar"
//得到Editor工具条
ICommandItem barItem = commandBars.Find(barID, false, false);
if (barItem != null && barItem.Type == esriCommandTypes.esriCmdTypeToolbar)
{
  ESRI.ArcGIS.Framework.ICommandBar commandBar = (ESRI.ArcGIS.Framework.ICommandBar)barItem;
   //打开Editor工具条
   commandBar.Dock(esriDockFlags.esriDockShow, null);
IEngineEditLayers editLayers = editor as IEngineEditLayers;
  IFeatureLayer featureLayer = waterLayer as IFeatureLayer;
  IDataset dataset = featureLayer.FeatureClass as IDataset;
  IWorkspace workspace = dataset.Workspace;

  UID editorID = new UIDClass();
  editorID.Value = "esriEditor.Editor";
  IEditor editor = m_application.FindExtensionByCLSID(editorID) as IEditor;
    if (editor != null)
  {
    editor.StartEditing(workspace);
  }
  else
  {
    MessageBox.Show("不可编辑,请确认图层没有被其它程序打开。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  }
}

 

posted on 2014-01-14 14:43  岁月静好  阅读(462)  评论(0编辑  收藏  举报

导航