예제 #1
0
 private void FillValue()//初始化DataGridView的部分移动到了此函数中
 {
     //增加ID列
     dataGridView1.Columns.Add("ID", "ID");
     //增加其他列 用以记录所有字段
     for (int i = 0; i < Layer.Fields.Count; i++)
     {
         dataGridView1.Columns.Add(Layer.Fields[i].name, Layer.Fields[i].name);
     }
     //增加行
     for (int i = 0; i < Layer.FeatureCount(); i++)
     {
         dataGridView1.Rows.Add();
         //增加ID值
         dataGridView1.Rows[i].Cells[0].Value = Layer.GetFeature(i).ID;
         //增加其他属性值
         for (int j = 0; j < Layer.Fields.Count; j++)
         {
             dataGridView1.Rows[i].Cells[j + 1].Value = Layer.GetFeature(i).getAttribute(j);
         }
         //确定每行的选择状态
         dataGridView1.Rows[i].Selected = Layer.GetFeature(i).Selected;
     }
 }
예제 #2
0
파일: Form2.cs 프로젝트: JokerDLord/GISbook
 public Form2(GISLayer layer)
 {
     InitializeComponent();
     for (int i = 0; i < layer.Fields.Count; i++) //添加一系列的列
     {
         dataGridView1.Columns.Add(layer.Fields[i].name, layer.Fields[i].name);
     }
     for (int i = 0; i < layer.FeatureCount(); i++)
     {
         dataGridView1.Rows.Add();
         for (int j = 0; j < layer.Fields.Count; j++)
         {
             dataGridView1.Rows[i].Cells[j].Value = layer.GetFeature(i).getAttribute(j);
         }
     }
 }