/// <summary>
        /// 删除字段
        /// </summary>
        /// <param name="pFeatureClass"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool DeleteField(IFeatureClass pFeatureClass, string name)
        {
            int index = pFeatureClass.Fields.FindField(name);

            if (index < 0)
            {
                return(false);
            }
            IField pField = pFeatureClass.Fields.get_Field(index);
            IClass pClass = pFeatureClass as IClass;

            pClass.DeleteField(pField);
            return(true);
        }
Ejemplo n.º 2
0
 public override void OnClick()
 {
     try
     {
         IClass pClass = _menuStrip.TableView.FeatureLayer.FeatureClass;
         IField pField = pClass.Fields.Field[_menuStrip.ColumnIndex];
         string msg    = $"确定要删除字段:{pField.Name}?";
         if (MessageBox.Show(msg, null, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             pClass.DeleteField(pField);
             _menuStrip.TableView.VirtualGridView.RemoveField(_menuStrip.ColumnIndex);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }