public void AddM() { Database db = HostApplicationServices.WorkingDatabase; Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; try { m_ContextMenu = new Autodesk.AutoCAD.Windows.ContextMenuExtension(); m_ContextMenu.Title = "工程图系统"; Autodesk.AutoCAD.Windows.MenuItem mi; mi = new Autodesk.AutoCAD.Windows.MenuItem("用户管理"); mi.Click += new EventHandler(MenuUserM_OnClick); //mi.Click += MenuUserM_OnClick; m_ContextMenu.MenuItems.Add(mi); Autodesk.AutoCAD.ApplicationServices.Application.AddDefaultContextMenuExtension(m_ContextMenu); } catch (System.Exception ex) { ed.WriteMessage("\nError: " + ex.Message + "\n"); } }