如何使用vb.Net从gridview搜索单行? [英] How can I search single row from gridview using vb.Net?

查看:60
本文介绍了如何使用vb.Net从gridview搜索单行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用vb.net代码从gridview搜索单个行?

How can I search single row from gridview using vb.net code?

推荐答案

您具体遇到什么问题?抓住想要的行吗?还是检查该行中的每个单元格?您在寻找什么?

要检查行中的每个单元格,您将要遍历网格的列.您可以这样操作:

What specifically are you having trouble with? Grabbing the row you want? Or checking each cell in that row? What are you searching for?

To check each cell in the row, you will want to loop through the grid''s columns. You can do that like this:

'In my example, I have a column in my grid called id.  I'm only grabbing rows that have a id that matches my variable strRowIdToSelect
For Each dgvr as DataGridViewRow in myDataGrid.Select("id=" & strRowIdToSelect)
   For Each dgvc as DataGridViewColumn In myDataGrid.Columns
      'The value I'm searching for is stored in a a variable called strValueToSearchFor
      If dgvr.Cells(dgvc.Index).Value = strValueToSearchFor Then
         'Found the value
         'Add code to do what you want after you've found it
      End
   Next
Next


这篇关于如何使用vb.Net从gridview搜索单行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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