陌生的不再陌生

导航

Dotspatial 图层添加字段和删除字段

//===============图层添加字段
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.");
}

posted on 2020-02-06 15:10  陌生的不再陌生  阅读(542)  评论(0编辑  收藏  举报