HawkeyeD
April 2nd, 2009, 02:17 AM
Hello all,
I am having a problem displaying a custom array list I have in my code. (BTW. It is 1am where I am. I have been at this for a long time so I apologize if I don't make a lot of sense).
I built an arraylist of objects from a custom class. The arraylist contains 2 columns\dimensions.
The first is type string, the second decimal.
I am now attempting to take my arraylist and display it in my form. I have tried using a listview and iterating through it, but unsure of how to split the two columns up. I have tried something similar to the following I found in another forum:
For i As Integer = 0 To arSearchArray.Count - 1
Dim item As String = CType(arSearchArray(i), String)
Dim arrItem() = Split(item, "___")
Dim url As String = arrItem(0)
Dim weight As String = arrItem(1)
Dim lstItem As New ListViewItem(url, 0)
lstItem.SubItems.Add(weight)
lstSearchResults.Items.Add(lstItem)
Next
but of course because the arraylist is a custom list it doesn't like me trying to cast it as a string. Plus I don't know if my split delimiter would work. Again, that is not my code, but code I found on another site.
I then tried a datagridview. But unsure about how to proceed. I created my datagridview on my form, but when I bind nothing happens. I know I am missing something as I am sure I will need more than just
dgSearchResults.DataSource = arSearchArray
however, my brain has decided to shut down now and so I will see if someone else much smarter\experienced then me can help out.
Please don't suggest I try and store my data in something else than the arraylist as I have written a lot of code around this including custom sorting code and going back to the drawing board is not an option (this is for a school project due soon).
Thanks again in advance.
I am having a problem displaying a custom array list I have in my code. (BTW. It is 1am where I am. I have been at this for a long time so I apologize if I don't make a lot of sense).
I built an arraylist of objects from a custom class. The arraylist contains 2 columns\dimensions.
The first is type string, the second decimal.
I am now attempting to take my arraylist and display it in my form. I have tried using a listview and iterating through it, but unsure of how to split the two columns up. I have tried something similar to the following I found in another forum:
For i As Integer = 0 To arSearchArray.Count - 1
Dim item As String = CType(arSearchArray(i), String)
Dim arrItem() = Split(item, "___")
Dim url As String = arrItem(0)
Dim weight As String = arrItem(1)
Dim lstItem As New ListViewItem(url, 0)
lstItem.SubItems.Add(weight)
lstSearchResults.Items.Add(lstItem)
Next
but of course because the arraylist is a custom list it doesn't like me trying to cast it as a string. Plus I don't know if my split delimiter would work. Again, that is not my code, but code I found on another site.
I then tried a datagridview. But unsure about how to proceed. I created my datagridview on my form, but when I bind nothing happens. I know I am missing something as I am sure I will need more than just
dgSearchResults.DataSource = arSearchArray
however, my brain has decided to shut down now and so I will see if someone else much smarter\experienced then me can help out.
Please don't suggest I try and store my data in something else than the arraylist as I have written a lot of code around this including custom sorting code and going back to the drawing board is not an option (this is for a school project due soon).
Thanks again in advance.