如何遍历datagridview的所有行并从中检索每个行的单元格值 [英] how to loop through all rows of a datagridview and retrieve each rows cell values from it

查看:1074
本文介绍了如何遍历datagridview的所有行并从中检索每个行的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遍历 datagridview 的每一行并检索每一行的单元格值,但它没有发生我尝试过这段代码:

 对于 每个 As  DataGridView  GridView2.Rows 
if row.isnewrow 然后
grno = row.cells( 0 )。value.tostring
name = row.cells( 1 )。value.tostring
end if //
Next



它给我异常,因为 isnewrow 不是 system.windows.forms.datagridview的成员



有人可以指导我完成这个吗?

解决方案

我认为它应该是

 对于 每个作为 DataGridView   GridView2中。行


I am trying to loop through each row of my datagridview and retrieve each row''s cell values, but it is not happening I have tried this code:

For Each row As DataGridView In GridView2.Rows
    if not row.isnewrow then
        grno=row.cells(0).value.tostring
        name=row.cells(1).value.tostring
    end if  // 
Next row


It is giving me exception as isnewrow is not a member of system.windows.forms.datagridview

Can anybody guide me through this?

解决方案

I believe it should be

For Each row As DataGridViewRow In GridView2.Rows

.


这篇关于如何遍历datagridview的所有行并从中检索每个行的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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