控制TOC控件中图层名称的修改 首先在Form_Load中添加如下代码: this.tocControl1.LabelEdit = esriTOCControlEdit.esriTOCControlManual; 然后,在TOCControl中重载OnBeginLabelEdit或OnEndLabelEdit事件,其中前者在用户开始修改图层名之前被触发,后者在修改完成之后被触发。 private void tocControl1_OnBeginLabelEdit(object sender,ITOCControlEvents_OnBeginLabelEditEvent e) { if (((ILayer)((Hashtable)((AxTOCControl)sender).CustomProperty)["0"]).Name == "testLayerName") { MessageBox.Show("testLayerName图层的图层名不能修改"); e.canEdit = false; } } private void tocControl1_OnEndLabelEdit(object sender,ITOCControlEvents_OnEndLabelEditEvent e) { if (e.newLabel == "") { MessageBox.Show("图层名不能为空"); e.canEdit = false; } }