删除基于两列的重复行 [英] Remove Duplicate row based off two columns

查看:119
本文介绍了删除基于两列的重复行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序可扫描我的整个IP范围,以查找每个响应设备上安装的软件。目前我手动获取数据,将datagridview复制到excel并删除基于2列的重复项。

I have an app that scans my entire IP range for software installed on each responding device. Currently I manually take the data, copy the datagridview into excel and remove duplicates based off 2 columns.

有没有办法将两个列行值与datagridview的其余部分进行比较以删除重复项?

Is there a way to compare two column row values against the rest of a datagridview to remove duplicates?

Ex。我有4列,我想检查列A& C值对数据网格视图中的所有其他行,删除或不插入值,它已经匹配A&中具有相同值的行。 C.

Ex. I have 4 column, and I want to check columns A & C values against all other rows in the datagrid view, removing, or not inserting the value is it already matches a row with the same values in A & C.

所以使用下面的例子Row1& Row3将匹配,因此Row3将不会被输入,或者它将被删除(如果唯一选项是清理例程与DGView.Rows.Add()上的检查,则删除

So using the below exampled Row1 & Row3 would match so Row3 would either no be entered, or it would be removed (removed if the only option is a cleanup routine verses a check on DGView.Rows.Add()

第1列         2           3         4

row1               B          C            D

row1       A        B          C           D

row2       A                  D           B

row2       A        C          D           B

第3行      A       B            C           E

row3       A       B           C           E

row4        B       C           d           D

row4       B       C           D           D

推荐答案

如果你使用绑定源,你可能会做这样的事情

If you use a bindingsource you might do something like this

        For Each DrowView As DataRowView In bs
            Dim idx As Integer = bs.Find("ColumnToSearch", DrowView("SearchString").ToString)
            If idx > 0 Then
                'matches found
                bs.RemoveAt(idx)
            End If
        Next




<理论是它应该留下一排匹配。这对于大型数据集来说可能有点慢,但是你说这是一个子网所以不用担心...

Theory is it should leave 1 row that matches behind. This could be a bit slow on large datasets, but you say this is for a subnet so no worry there...


这篇关于删除基于两列的重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆