我加載一個DataGridView,我試圖找到通過某列循環的快捷方式,給定列名....通過特定的數據集列循環,以檢查其中是否包含一定值
這是怎麼了我的datagridview加載....
ad = New SqlDataAdapter(sql, con)
ad.Fill(ds, "Fields")
dgvFields.DataSource = ds.Tables("Fields")
dgvFields.ReadOnly = True
dgvFields.RowHeadersVisible = False
dgvFields.Columns(0).Width = 156
dgvFields.Columns(1).Width = 156
dgvFields.Columns(2).Width = 156
dgvFields.Columns(3).Width = 157
「現在我希望能夠遍歷dgvfields.columns(3)或列名‘Field1a’,並檢查是否dgvfields.rows =‘值a’
沿線...
For Each row As DataRow In dgvFields.Columns(5)
if dgvfields.rows.value="ValueA" then
'do something
End if
Next
掃描數據表而不是控件 - 代碼段正在混合並匹配DT和DGV元素。請參閱[獲取DataGridView單元格值](http://stackoverflow.com/questions/40552536/get-datagridview-cell-value-in-nested-for-loops/40556752#40556752)瞭解vb,循環版本 – Plutonix