Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Easiest way to loop thru cells in a DataGridView?

$
0
0
I am seeking to loop thru all the cells in my dgv. I though you could do something like this:

Code:

    For Each cell In DGV.Cells
    Next

Unfortunately the above code doesn't work. There is no Cells class at this level. Is this the only other way?

Code:

            For Each row As DataGridViewRow In dgv.Rows
                For Each col As DataGridViewColumn In dgv.Columns
                    Select Case col.Index
                        Case 3 To 6
                            col.ReadOnly = True
                    End Select
                Next
            Next

By the way, the above code isn't working. For some reason I can still access these columns. They are checkbox columns so I'm wondering if that makes a difference?

Thanks

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>