Visual Basic, How do I read each row in a datagrid?

后端 未结 1 1009
我寻月下人不归
我寻月下人不归 2021-01-12 02:48

I have a datagrid called DataGridView1, column A contains a name, column B contains a path to a file. How do I run some code for each row? What is the correct terminology fo

相关标签:
1条回答
  • 2021-01-12 03:34

    You were nearly there, you need something like the following:

    For Each row As DataGridViewRow In DataGridView1.Rows
        If Not row.IsNewRow Then
            MessageBox.Show(row.Cells(0).Value.ToString & "," & row.Cells(1).Value.ToString)
        End If
    Next
    

    EDIT:

    You need to check if the row.IsNewRow is not True if your DataGridView allows adding rows.

    0 讨论(0)
提交回复
热议问题