private void btnDel_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dgv.SelectedRows)
     {
         TechnologyProduct tp = row.Tag as TechnologyProduct;
         dgv.Rows.Remove(row);
         technology.Table.Remove(tp);
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TechnologyProduct tp = new TechnologyProduct();
            int index            = dgv.Rows.Add();

            dgv.Rows[index].Tag = tp;
            technology.Table.Add(tp);
            UpdateDataOfRow(dgv.Rows[index]);
        }
        /// <summary>
        /// 获取已选择的技术
        /// </summary>
        private List <TechnologyProduct> GetCheckedTechnologies()
        {
            List <TechnologyProduct> checkedTechnologies = new List <TechnologyProduct>();

            foreach (DataGridViewRow row in dgv.Rows)
            {
                if (Convert.ToBoolean(row.Cells[ColumnState].Value))// 勾选
                {
                    TechnologyProduct tp = (TechnologyProduct)row.Tag;
                    checkedTechnologies.Add(tp);
                }
            }
            return(checkedTechnologies);
        }
        private void UpdateDataOfRow(DataGridViewRow row)
        {
            // 没有行数,返回
            if (row.Tag == null)
            {
                return;
            }

            TechnologyProduct tp = (TechnologyProduct)row.Tag;

            tp.Name = row.Cells[0].Value == null ? string.Empty : row.Cells[0].Value.ToString();
            tp.URL  = row.Cells[1].Value == null ? string.Empty : row.Cells[1].Value.ToString();
            string items = row.Cells[2].Value == null ? string.Empty : row.Cells[2].Value.ToString();

            tp.Items = items.Split(ItemSplitStyles, StringSplitOptions.RemoveEmptyEntries)
                       .Select(s => s.Replace("条", "").Trim())
                       .Distinct().ToList();
            // 最后更新时间
            tp.LatestUpdateTime = row.Cells[3].Value == null ? new DateTime()
                : Convert.ToDateTime(row.Cells[3].Value);
        }