Putting an Array into Datagrid

ayozzhero

Well-known member
Joined
Apr 6, 2005
Messages
186
Location
Malaysia
Programming Experience
1-3
Let's say this is the code:
Dim No(10) As Integer
Dim UserName(10) As String
Dim ICNo(10) As String

'... some connection strings and processes go here

Dim i As Integer
i = 1
While myDR.read And i <= 10
No(i) = i
UserName(i) = myDR("UserName")
ICNo(i) = myDR("ICNo")
i = i + 1
End While
How is it to transform the arrays to the DataGrid. Currently I read all data from database to data adapters directly, and then I refer the datagrid to the data adapter. But that way is not very flexible. In VB 6, I can just add data to cells straight away but I can't fint the way in VB .Net
 
If you are not using bound data, i.e. your data is not already in a table, you can simply write a value to a DataGrid cell using the Item property. Be aware, though, that using a bound DataTable makes committing changes back to a database much simpler.
 
Back
Top