|
-
Jun 16th, 2010, 02:08 PM
#1
Thread Starter
Lively Member
Confused on how datagridviews work. :(
I want to make a database of all the xbox live arcade arcade games on the xbox live marketplace, I need to parse an xml file and add the needed data from the xml node into a datagridview.
Here is the xml file i need to use to grab links and other data about the game:
http://updates.xboxmodder.com/updates.xml
Being the noob I am it took me about 6 hours to figure out how xml works and to write some code for what i need to do.
Here is what i came up with:
Code:
'for grabbing the name of the update
Public Sub updatename()
Dim xmldoc As New XmlDataDocument()
Dim xmlnode As XmlNodeList
Dim i As Integer
Dim str As String
xmldoc.Load("http://updates.xboxmodder.com/updates.xml")
xmlnode = xmldoc.GetElementsByTagName("file")
For i = 0 To xmlnode.Count - 1
xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
str = xmlnode(i).ChildNodes.Item(1).InnerText.Trim()
DataGridView1.Rows.Add(str)
Next
end sub
That code works fine.
Now when i add another column to the datagridview called "update size" i want to know how to add the grabbed data from another sub i made to the new column.
What would the code be for adding the strings for the new sub into the seconds column? the first was, DataGridView1.Rows.Add(str)" . So what would the second be ?
Also another question i have is how do i put an image in an imagecolumn by a web link, not a local picture.
Please go easy on me, i'm still learning and havent even started my programming classes yet , just trying to prepare for it and learn by making programs for my needs.
Thanks.
-
Jun 16th, 2010, 02:19 PM
#2
Re: Confused on how datagridviews work. :(
can you post the 2nd sub?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 16th, 2010, 02:23 PM
#3
Re: Confused on how datagridviews work. :(
here's a simple example, but you'll probably need to tie in column2 with the values in column1:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGridView1.Columns.Add("Column2", "Column2")
For x As Integer = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(x).Cells(1).Value = x
Next
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 16th, 2010, 02:31 PM
#4
Re: Confused on how datagridviews work. :(
 Originally Posted by JJMPSP
Also another question i have is how do i put an image in an imagecolumn by a web link, not a local picture.
try this:
vb.net Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim t As New Threading.Thread(AddressOf addImages)
t.Start(DataGridView1)
End Sub
Private Delegate Sub addImagesCallback(ByVal dgv As Object)
Private Sub addImages(ByVal dgv As Object)
If DirectCast(dgv, DataGridView).InvokeRequired Then
DirectCast(dgv, DataGridView).Invoke(New addImagesCallback(AddressOf addImages), dgv)
Else
Dim MyWebClient As New System.Net.WebClient
DirectCast(dgv, DataGridView).Columns.Add(New DataGridViewImageColumn)
For x As Integer = 0 To DirectCast(dgv, DataGridView).Rows.Count - 1
Dim ImageInBytes() As Byte = MyWebClient.DownloadData("url")
Application.DoEvents()
DirectCast(dgv, DataGridView).Rows(x).Cells(DirectCast(dgv, DataGridView).Columns.Count - 1).Value = Image.FromStream(New IO.MemoryStream(ImageInBytes))
Next
End If
End Sub
Last edited by .paul.; Jun 16th, 2010 at 03:11 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 16th, 2010, 03:51 PM
#5
Lively Member
Re: Confused on how datagridviews work. :(
If you already have the second column made, then you can do this;
vb Code:
Dim dgvR as DataGridViewRow Dim x as Integer = 0 For Each dgvR in DataGridView1.Rows dgvR.Cells.Item(1).Value = xmlnode(x).ChildNodes.Item(1).InnerText.Trim() x += 1 Next
Change the 1 in "dgvR.Cells.Item(1).Value" to whatever column you want filled in each row.
xmlNode = list of data to loop through and append.
This is just one of many ways..
Personally, I would fill both columns at the same time instead of one column at a time.
Last edited by MotoX646; Jun 16th, 2010 at 03:57 PM.
-
Jun 17th, 2010, 04:35 PM
#6
Thread Starter
Lively Member
Re: Confused on how datagridviews work. :(
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|