private void FillDgv_Data() { Dgv_Data.Rows.Clear(); for (int _i = 0; _i < _LstShow.Count; _i++) //循环方案对象 { CLDC_DataCore.Struct.StPlan_ConnProtocol _Item = _LstShow[_i]; //取出一个方案项目 string zouziShortDecript = string.Empty; int RowIndex = Dgv_Data.Rows.Add(); Dgv_Data.Rows[RowIndex].Cells[0].Value = _i + 1; ((DataGridViewComboBoxCell)Dgv_Data.Rows[RowIndex].Cells[1]).Value = _Item.ConnProtocolItem.ToString(); //数据项名称 ((DataGridViewCell)Dgv_Data.Rows[RowIndex].Cells[2]).Value = _Item.ItemCode; //标识编码 ((DataGridViewCell)Dgv_Data.Rows[RowIndex].Cells[3]).Value = _Item.DataLen.ToString(); //数据长度 ((DataGridViewCell)Dgv_Data.Rows[RowIndex].Cells[4]).Value = _Item.PointIndex.ToString(); //小数位索引 ((DataGridViewCell)Dgv_Data.Rows[RowIndex].Cells[5]).Value = _Item.StrDataType; //数据格式 //((DataGridViewComboBoxCell)Dgv_Data.Rows[RowIndex].Cells[6]).Value = _Item.OperType.ToString(); //操作类型,读/写 //((DataGridViewCell)Dgv_Data.Rows[RowIndex].Cells[7]).Value = _Item.WriteContent; //写入内容 Dgv_Data.Rows[RowIndex].Cells[Dgv_Data.Columns.Count - 1].Value = "删除"; //删除按钮 Dgv_Data[Dgv_Data.Columns.Count - 1, RowIndex].Style.ForeColor = Color.Red; //删除按钮为红色 } { int RowIndex = Dgv_Data.Rows.Add(); //最后增加一个空行,用于新增 Dgv_Data.Rows[RowIndex].Cells[Dgv_Data.Columns.Count - 1].Value = CONST_ADD; Dgv_Data.Rows[RowIndex].Cells[Dgv_Data.Columns.Count - 1].Style.ForeColor = Color.Blue; } this.UpDownButtonState(0); //设置上下移动按钮状态 }
private void setLstShow(string p) { _LstShow.Clear(); if (string.IsNullOrEmpty(p)) { return; } string[] _parms = p.Split(','); int _pcount = _parms.Length; for (int i = 0; i < _pcount; i++) { string[] pcell = _parms[i].Split('|'); CLDC_DataCore.Struct.StPlan_ConnProtocol stcn = new CLDC_DataCore.Struct.StPlan_ConnProtocol(); stcn.ConnProtocolItem = pcell[1]; stcn.DataLen = int.Parse(pcell[3]); stcn.ItemCode = pcell[2]; stcn.OperType = CLDC_DataCore.Struct.StMeterOperType.读; stcn.PointIndex = int.Parse(pcell[4]); stcn.StrDataType = pcell[5]; stcn.WriteContent = ""; stcn.PrjID = pcell[0]; _LstShow.Add(stcn); } }