Beispiel #1
0
 //删除ROI
 private void ROIDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 0 && e.RowIndex < ROIDataGridView.Rows.Count)
         {
             IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(ROIFileNames[e.RowIndex]);
             IDataset      dataSet      = featureClass as IDataset;
             if (dataSet.CanDelete())
             {
                 dataSet.Delete();
             }
             else
             {
                 throw new Exception("删除数据集出错。");
             }
             ROIDataGridView.Rows.RemoveAt(e.RowIndex);
             ROINames.RemoveAt(e.RowIndex);
             ROIColors.RemoveAt(e.RowIndex);
             ROIFileNames.RemoveAt(e.RowIndex);
             m_mapControl.DeleteLayer(e.RowIndex);
             axTOCControl1.Refresh();
             if (ROIDataGridView.Rows.Count < 1)
             {
                 ChangeEditingIndex(-1);
             }
             else if (ROIDataGridView.Rows.Count < EditingIndex + 1)
             {
                 ChangeEditingIndex(0);
             }
         }
         else if (e.RowIndex < ROIDataGridView.Rows.Count)
         {
             ChangeEditingIndex(e.RowIndex);
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.ToString());
     }
 }