将选定的行值与另一个行值进行比较 [英] Compare selected row value to another row value

查看:59
本文介绍了将选定的行值与另一个行值进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我从gridview中检索了一个单元格值(例如,CustName Peter)(例如grdView)。然后我想将它与gridview中的其余记录(使用循环)进行比较。我该怎么做。任何帮助将不胜感激。

hello, I have retrieved a cell value(eg. CustName Peter) from gridview(eg. grdView). Then I want to compare it with the rest of the records in gridview(using loop). How can I do it. Any help would be appreciated.

推荐答案

使用foreach循环

ex :(在VB.Net中)

Use a foreach loop
ex: (in VB.Net)
Dim name As String = "CustName"
Dim columnIndex As Integer = 1
'this is the column index which contains the value to compare

For Each dr As DataGridViewRow In DataGridView1.Rows
    If name = dr.Cells.Item(columnIndex).Value Then
        'do anything
    End If
Next dr





希望这会有所帮助..

问候



Hope this helps..
Regards


这篇关于将选定的行值与另一个行值进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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