Results 1 to 6 of 6

Thread: Datagrid Column into an array

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    12

    Datagrid Column into an array

    How do i store a datagrid column values into an array?

  2. #2
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    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.

  3. #3
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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

  4. #4
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    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")).
    Lol this is exactly what I thought he wanted. Oh well must not be understanding people well anymore.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    12
    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).

  6. #6
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    What you want to do sounds very like the DataSet.Merge method?

    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataSetClassMergeTopic2.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width