码迷,mamicode.com
首页 > 其他好文 > 详细

superMap Object 属性查看的一点代码

时间:2014-07-31 16:10:46      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:des   datagridview   style   blog   color   os   io   for   

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HZZYKJ.IDRMIS.CORE;
using SuperMap.Mapping;
using SuperMap.UI;
using SuperMap.Data;
using HZZYKJ.IDRMIS.EDIM.Tools;
using HZZYKJ.IDRMIS.EDIM.toolClass;

namespace HZZYKJ.IDRMIS.EDIM
{
    public partial class AttributeTreeForm : Form
    {
        private MapControl mapControl;
        private List<Layer> layers = new List<Layer>();
        public static AttributeTreeForm _AttributeTreeForm = null;

        public AttributeTreeForm()
        {
            InitializeComponent();
            mapControl = AppContext.MapControl as MapControl;         
        }

        private void AttributeTreeForm_Load(object sender, EventArgs e)
        {        
            Layers layers = mapControl.Map.Layers;
            foreach (Layer item in layers)
            {
                this.layers.Add(item);
                
            }       
            Layer layer = this.layers[LayerForm._layerform.comboBox1.SelectedIndex];
            Selection selection = layer.Selection;
            Recordset recordset = selection.ToRecordset();

            TreeNode TN_Layer_Father = new TreeNode(layer.Name);
            treeView1.Nodes.Add(TN_Layer_Father);   

            for (int i = 0; i < recordset.RecordCount; i++)
            {                
                string name = recordset.GetFieldValue(0).ToString();
                TreeNode TN_Fild_Child = new TreeNode(name);
                TN_Layer_Father.Nodes.Add(TN_Fild_Child);         
                 recordset.MoveNext();               
            }
           this.treeView1.SelectedNode = this.treeView1.Nodes[0].Nodes[0];
            treeView1.ExpandAll();                 
            
        }




        private void AttributeTreeForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            _AttributeTreeForm = null;
        }





        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
                
        }




        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            BindingList<FieldInfoName> GridBindingList = new BindingList<FieldInfoName>();
          //  List<FieldInfoName> GridList = new List<FieldInfoName>();
            if (this.treeView1.SelectedNode.Parent != null)
            {
                Layers layers = mapControl.Map.Layers;
                foreach (Layer item in layers)
                {
                    this.layers.Add(item);

                }
                Layer layer = this.layers[LayerForm._layerform.comboBox1.SelectedIndex];
                Selection selection = layer.Selection;
                Recordset recordset = selection.ToRecordset();
                
                FieldInfos fieldinfos = recordset.GetFieldInfos();

                for (int i = 0; i < recordset.RecordCount; i++)
                {
                    if (this.treeView1.SelectedNode.Text == recordset.GetFieldValue(0).ToString())
                    {
                        for (int j = 0; j < recordset.FieldCount; j++)
                        {
                            
                                if (this.checkBox1.Checked == false)
                                {
                                    string x = fieldinfos[j].Name;
                                    string y = null;
                                    if (recordset.GetFieldValue(j).ToString() == null)
                                    {
                                         y = null;
                                    }
                                    else
                                    {
                                         y = recordset.GetFieldValue(j).ToString();//总是出错
                                    }
                                    FieldInfoName FIN = new FieldInfoName(x, y);
                                    GridBindingList.Add(FIN);
                                }
                                else
                                {
                                    if (fieldinfos[j].IsSystemField == false)
                                    {
                                        string x = fieldinfos[j].Name;
                                        string y = recordset.GetFieldValue(j).ToString();
                                        FieldInfoName FIN = new FieldInfoName(x, y);
                                        GridBindingList.Add(FIN);
                                    }
                                }
                        }
                    }
                    recordset.MoveNext();
                }

                this.dataGridView1.DataSource = GridBindingList;
            }
            else
            {
                MessageBox.Show("请选择子节点");
            }

        }

        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {

       
     
        }

        private void btn_Ok_Click(object sender, EventArgs e)
        {
            Layers layers = mapControl.Map.Layers;
            foreach (Layer item in layers)
            {
                this.layers.Add(item);

            }
            Layer layer = this.layers[LayerForm._layerform.comboBox1.SelectedIndex];
            Selection selection = layer.Selection;
            Recordset recordset = selection.ToRecordset();
            FieldInfos fieldinfos = recordset.GetFieldInfos();
           
                for (int i = 0; i < recordset.RecordCount; i++)
                {
                    if (this.treeView1.SelectedNode.Text == recordset.GetFieldValue(0).ToString())
                    {
                        for (int j = 0; j < recordset.FieldCount; j++)
                        {
                            if (fieldinfos[j].IsSystemField == false)
                            {
                                recordset.Edit();
                                string a = this.dataGridView1.Rows[j].Cells[1].Value.ToString();
                                recordset.SetFieldValue(j, a);
                                recordset.Update();
                            }
                        }                     
                    }
                    recordset.MoveNext();
                }

                MessageBox.Show("属性值修改成功");
        }




        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
          
        }

    }
}

 



superMap Object 属性查看的一点代码,布布扣,bubuko.com

superMap Object 属性查看的一点代码

标签:des   datagridview   style   blog   color   os   io   for   

原文地址:http://www.cnblogs.com/sjfsjf/p/3880624.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!