private void btResetTag_Click(object sender, EventArgs e)
 {
     if (m_portConfig != null)
     {
         m_datatable = m_portConfig.CreateDataTable();
         if (m_datatable != null)
         {
             DataSet dataset = (DataSet)(dgvPortConfig.DataSource);
             if (dataset != null)
             {
                 dataset.Dispose();
             }
             dataset = new DataSet();
             dataset.Tables.Add(m_datatable);
             dgvPortConfig.DataSource = dataset;
             dgvPortConfig.DataMember = "PortConfig";
         }
     }
 }
        public PortConfigEditForm(PortConfig[] portConfig)
        {
            InitializeComponent();
            //m_xmlDoc = new XmlDocument();
            //m_xmlDoc.LoadXml(Config.Resource.Description);
            //string nodeString = "PortConfig";
            //XmlNodeList nodeList;
            m_portConfig         = portConfig[0];
            m_portConfig_default = portConfig[1];
            m_datatable          = m_portConfig.CreateDataTable();
            m_datatable_default  = portConfig[1].CreateDataTable();
            this.Text            = m_portConfig.GetName();
            tbComment.Text       = m_portConfig.m_comment;
            if (m_datatable != null)
            {
                DataSet dataset = new DataSet();
                dataset.Tables.Add(m_datatable);
                dgvPortConfig.DataSource = dataset;
                dgvPortConfig.DataMember = "PortConfig";
                //tbComment.Text = dgvPortConfig.CurrentRow.Cells[2].Value;
                //dgvPortConfig.Columns[dgvPortConfig.Columns.Count - 1].Visible = false;
            }

            /*
             * switch(m_portConfig.m_type)
             * {
             *  case Config.EditType.EDIT_PORT_CONFIG:
             *      nodeString = "PortConfig";
             *      break;
             *  case Config.EditType.EDIT_PORT_COMMAND:
             *      nodeString = "PortCommands";
             *      break;
             *  case Config.EditType.EDIT_PCPORT_CONFIG:
             *      nodeString = "PCPortConfig";
             *      break;
             *  case Config.EditType.EDIT_PCPORT_COMMAND:
             *      nodeString = "PCPortCommands";
             *      break;
             *  case Config.EditType.EDIT_ETHERNET_CONFIG:
             *      nodeString = "EthernetConfig";
             *      break;
             *  case Config.EditType.EDIT_ETHERNET_CLIENT_CONFIG:
             *      nodeString = "EthernetClientConfig";
             *      break;
             *  case Config.EditType.EDIT_ETHERNET_CLIENT_COMMAND:
             *      nodeString = "EthernetClientCommands";
             *      break;
             *  case Config.EditType.EDIT_ETHERNET_SERVER_CONFIG:
             *      nodeString = "EthernetServerConfig";
             *      break;
             *  case Config.EditType.EDIT_DATA_REMAP:
             *      nodeString = "DataRemap";
             *      break;
             *  default:
             *      break;
             * }
             * nodeList = m_xmlDoc.SelectSingleNode("modbus").ChildNodes;
             * foreach (XmlNode xn in nodeList)
             * {
             *  XmlElement xe = (XmlElement)xn;//将子节点类型转换为XmlElement类型
             *  if (xe.Name == nodeString)//如果name属性值为tbCfgName.Text
             *  {
             *      m_nodeList = xe.ChildNodes;
             *      break;
             *  }
             * }
             */
        }