private void btn_add_Click(object sender, EventArgs e)
        {
            string str_P_ID = "";
            string str_P_Type = "";
            string str_P_Name = "";

int count = Convert.ToInt32(Dgv_Search.Rows.Count.ToString());
            for (int i = 0; i < count; i++)
            {
                //如果DataGridView是可编辑的,将数据提交,否则处于编辑状态的行无法取到
                Dgv_Search.EndEdit();

DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)Dgv_Search.Rows[i].Cells["ckb_check"];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag == true)     //查找被选择的数据行
                {
                    //从 DATAGRIDVIEW 中获取数据项
                    str_P_Type = Dgv_Search.Rows[i].Cells["类型"].Value.ToString().Trim();
                    str_P_ID = Dgv_Search.Rows[i].Cells["ID"].Value.ToString().Trim();
                    str_P_Name = Dgv_Search.Rows[i].Cells["名称"].Value.ToString().Trim();

string str_Same = "0";
                    for (int i2 = 0; i2 < DataSet_tb.Tables[0].Rows.Count; i2++)
                    {
                        if (str_P_ID == DataSet_tb.Tables[0].Rows[i2]["ID"].ToString())
                        {
                            str_Same = "1";
                            continue;
                        }
                    }

if (str_Same != "1")
                    {
                        DataRow row = DataSet_tb.Tables[0].NewRow();
                        row["类型"] = str_P_Type.ToString();
                        row["ID"] = str_P_ID.ToString();
                        row["名称"] = str_P_Name.ToString();
                        DataSet_tb.Tables[0].Rows.Add(row);
                    }
                }
            }

Dgv_Confirm.DataSource = DataSet_tb.Tables[0];
            Dgv_Confirm_Init();

}

20161020001 DataGridView 选中的 DataGridViewCheckBoxCell 不添加重复项的更多相关文章

  1. txt文本怎么去除重复项

    txt文本怎么去除重复项?做网络推广的朋友经常会遇到这样的问题,txt文本文件里面有许多人名或者电话号码用来发送邮件或者短信,通常有许多是重复的,下面我来介绍两个方法来去除重复项,以人名为范本讲解. ...

  2. 利用excel去除txt文本中重复项

    2017-04-10 1.要去重的文件,点击右键,选择程序. 2.选择excel表格或者wps表格. 3.excel表格去重:选中单元格——数据——筛选——高级筛选——选择不重复记录——确定 wps表 ...

  3. TListView列表拒绝添加重复信息

      //TListView列表拒绝添加重复信息 procedure TForm1.Button1Click(Sender: TObject);var  i: Integer;begin  if (Tr ...

  4. 不能添加重复的Contact到RecipientBox中

    不能添加重复的Contact到RecipientBox中 在开始添加的操作时,判断是否已在RecipientBox中,如果已经在返回值为null的TextView. 再根据TextView判断是否nu ...

  5. vue12 循环添加重复数据

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 多文件上传,添加重复文件时无法触发onchange事件。

    <input type="file" id="upload" @change="getFile($event)" multiple=& ...

  7. 为Array对象添加一个去除重复项的方法

    输入例子 [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a', 'a', NaN].uniq() 输出例子 [false, true, unde ...

  8. Vue 循环为选中的li列表添加效果

    <!DOCTYPE html><html><head> <meta charset="utf-8"> <title>Vu ...

  9. js去除数组重复项

    /** * js去除数组重复项 */ //方法一.使用正则法 // reg.test(str),匹配得到就返回true,匹配不到返回false var arr = ["345",& ...

随机推荐

  1. tensorfolw配置过程中遇到的一些问题及其解决过程的记录(配置SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real-Time Object Detection for Autonomous Driving)

    今天看到一篇关于检测的论文<SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real- ...

  2. Intellij 常用技巧-持续更新

    1.快速输入 System.out.println(); sout [TAB] 2.删除Module ctrl+alt+shift+s 调出  Project Structure ,也可点击菜单Fil ...

  3. Windows 64位 RabbitMQ 安装配置

    1:下载Erlang,地址:http://www.erlang.org/download/otp_win64_19.0.exe ,双击安装即可(首先装) 2:下载RabbitMQ,RabbitMQ 3 ...

  4. duilib各种布局的作用,相对布局与绝对布局的的意义与用法

    大多数刚使用duilib的朋友时候非常依赖duilib自带的设计器,用他可以拖拉控件,可视化的做出自己想要的界面.可是用一段时间就会发现原带的设计器有很多bug,时不时会崩溃,支持的控件数量有限,属性 ...

  5. leetcode 155

    题目描述: Design a stack that supports push, pop, top, and retrieving the minimum element in constant ti ...

  6. Hadoop中Combiner的使用

    注:转载自http://blog.csdn.net/ipolaris/article/details/8723782 在MapReduce中,当map生成的数据过大时,带宽就成了瓶颈,怎样精简压缩传给 ...

  7. windows10搭建django1.10.3+Apache2.4

    很多教程都是在linux上搭建,windows上似乎天生不太适合,但是我还是愿意试试这个坑. 首先 交代一下自己的环境 python3.5.2 64位 django 1.10.3 apache 2.4 ...

  8. oracle 9i相关问题

    Oracle 9i在连接数据库的时候需要加上双引号,如sqlplus “sys/oracle@orcl as sysdba” Oracle 9i不支持bigfile大的表空间创建,oracle9i或以 ...

  9. Google Code Jam Round 1A 2015 解题报告

    题目链接:https://code.google.com/codejam/contest/4224486/ Problem A. Mushroom Monster 这题题意就是,有N个时间点,每个时间 ...

  10. 搭建Android底层开发环境

    为了开发linux驱动方便些,我们一般将linux作为Android的开发环境,那么就需要搭建Android的开发环境,下面是一些搭建Android底层时的心得: (1)安装JDK:除了普遍使用的下载 ...