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. [dpdk] 熟悉SDK与初步使用 (二)(skeleton源码分析)

    接续前节:[dpdk] 熟悉SDK与初步使用 (一)(qemu搭建实验环境) 程序逻辑: 运行参数: 关键API: 入口函数: int rte_eal_init(int argc, char **ar ...

  2. js、css引用文件的下载方式

    js.css引用文件的下载方式 一.测试(chrome):1.直接使用<script...>.<link...>标签来混合引入脚本文件和css文件, <script as ...

  3. iOS用户信息单例的创建

    UserInfo.h + (UserInfo *) sharedInstance; UserInfo.m #import "UserInfo.h" static UserInfo ...

  4. ajax跨域通过 Cors跨域资源共享 进行GetPost请求

    using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Ne ...

  5. ORM系列之二:EF(1)

    目录 1. EF是什么 2. 如何获取EF 3. EF有哪些主要模式 EF是什么 EF全称为Entity Framework,是微软推荐的一种数据库访问技术,属于重量级的ORM框架,功能非常强大,目前 ...

  6. NGINX、PHP-FPM开机自动启动

    NGINX SHELL脚本   放到/etc/init.d/下取名nginx #!/bin/sh # # nginx - this script starts and stops the nginx ...

  7. Python之路----------shutil模块

    高级的文件.文件夹.压缩包 处理模块 复制文件: import shutil f1 = open('test') f2 = open('test2','w') shutil.copyfileobj(f ...

  8. iOS,非视图类方法

    1.判断类的实例 2.获取当前最高层Window 3.获取当前app是否活跃 4.允许所有请求 5.判断设备是否越狱 6.移除字符串换行符和空格 7.iOS注释方法或属性废弃或不可用 8.本地通讯录操 ...

  9. lua自定义迭代器

    迭代器 http://www.tutorialspoint.com/lua/lua_iterators.htm 迭代器能够让你遍历某个集合或者容器中的每一个元素. 对于lua来说, 集合通常指代 ta ...

  10. LUA table学习笔记

    function printT( ... ) for i,v in ipairs(...) do print(i,v) end end t1={} t2={} t3={} table.insert(t ...