How do i store a datagrid column values into an array?
Printable View
How do i store a datagrid column values into an array?
Try this:-
dim arrRow() as object
arrRow = dataset.tables("table").rows(rowindex).itemarray
I haven't tried it so I don't know if it will work.
I don't think so, I'm fairly sure that would get all the fields in one datarow (ItemArray is another way of referring to fields in a datarow, just in the form of an Array instead of .Item("Name")).
I don't think you want to do this directly from the datagrid, as the datagrid is just a mouthpiece for a datasource (unless of course you're typing in rows at runtime) - you may want to query the datasource and then work with the data it contains. May I ask why you want to turn the contents into an array? You may not really need to, you can for example:
Dim iCount as Integer
For iCount = 0 to (dsData.Tables("Table").Rows.Count - 1)
DoSomeFunction(dsData.Tables("Table").Rows(iCount).Items("Column"))
Next
Lol this is exactly what I thought he wanted. Oh well must not be understanding people well anymore.Quote:
Originally posted by Slow_Learner
I don't think so, I'm fairly sure that would get all the fields in one datarow (ItemArray is another way of referring to fields in a datarow, just in the form of an Array instead of .Item("Name")).
Thanks for the replies.
I want to use an array because, i have two datagrids and need to pull out contents from a column of the first datagrid and add it to a column in the second datagrid (If those entries are not already there).
What you want to do sounds very like the DataSet.Merge method?
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataSetClassMergeTopic2.htm