ds.Tables(0).Columns.Add("colunmname", GetType(String)) 'ds代表数据源
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
If CBool((ds.Tables(0).Rows(i)("colunmname"))) Then '更改那个字段的显示
ds.Tables(0).Rows(i)("colunmname") = "Y"
Else
ds.Tables(0).Rows(i)("colunmname") = "N"
End If
Next
Me.ds.AcceptChanges()
Me.gridviewname.DataSource = Me.ds.Tables(0)
'edit cell
Dim dr As Data.DataRow
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
dr = ds.Tables(0).Rows(i)
If CType(dr("colunmname"), Boolean) = True Then
Me.gridviewname.Rows(i).Cells(2).ReadOnly = False '指定单元格的只读属性
End If
Next
本文介绍了一种使用Visual Basic.NET来遍历数据集(ds)中的表格,并修改特定列(colunmname)显示的方法。根据列内容的布尔值,将单元格内容更改为“Y”或“N”,并调整GridView中相应行的只读属性。
3129

被折叠的 条评论
为什么被折叠?



