コード例 #1
0
        private void buttonDelAttribute_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除该属性字段?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    GSOFeatureLayer pFeatureLayer = geoLayer as GSOFeatureLayer;
                    if (pFeatureLayer == null)
                    {
                        return;
                    }
                    GSOFeatureDataset dataset = pFeatureLayer.Dataset as GSOFeatureDataset;

                    dataset.DeleteField(listBoxAttribute.SelectedItem.ToString());

                    if (listBoxAttribute.SelectedItem != null)
                    {
                        listBoxAttribute.Items.Remove(listBoxAttribute.SelectedItem);
                        dataset.SaveAs(@"F:\新建文件夹");
                        MessageBox.Show("删除字段成功!", "提示!");
                    }
                    if (m_globeControl != null)
                    {
                        m_globeControl.Refresh();
                    }
                }
                catch (System.Exception exp)
                {
                    Log.PublishTxt(exp);
                }
            }
        }
コード例 #2
0
 //删除
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (listViewFields.CheckedItems.Count <= 0)
     {
         MessageBox.Show("请选择要删除的字段!", "提示");
         return;
     }
     if (layer != null)
     {
         GSOFeatureDataset dataset = layer.Dataset as GSOFeatureDataset;
         if (dataset != null)
         {
             for (int i = 0; i < listViewFields.CheckedItems.Count; i++)
             {
                 string fieldName = listViewFields.CheckedItems[i].Text;
                 dataset.DeleteField(fieldName.Trim());
                 dataGridView1.Columns.Remove(fieldName.Trim());
             }
         }
     }
     this.Close();
 }