//===============图层添加字段
polygonFeatureSet = (FeatureSet)mapMain.Layers[0].DataSet;
polygonFeatureSet.Projection = mapMain.Projection;
polygonFeatureSet.FeatureType = FeatureType.Polygon;
DataColumn column = new DataColumn("IDxx", typeof(int));
if (!polygonFeatureSet.DataTable.Columns.Contains("IDxx"))
{
polygonFeatureSet.DataTable.Columns.Add(column);
}
polygonFeatureSet.Save();
//==============图层删除字段
if (mapMain.Layers.Count > 0)
{
MapPolygonLayer polygonLayer = default(MapPolygonLayer);
polygonLayer = (MapPolygonLayer)mapMain.Layers[0];
if (polygonLayer == null)
{
MessageBox.Show("The layer is not a polygon layer.");
}
else
{
polygonLayer.DataSet.DataTable.Columns.Remove("IDxx");
polygonLayer.DataSet.Save();
dataGridView1.DataSource = polygonLayer.DataSet.DataTable;
}
}
else
{
MessageBox.Show("Please add a layer to the map.");
}