VS 2010 BGW Array-VBForums
Results 1 to 2 of 2

Thread: BGW Array

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009

    BGW Array

    I have a background work reading an XML file. I want it to return an array of results which happen to be values.

    I want to be able to place all the values as a point on a panel as an X asis which will be lined up with a y+10 pixels on the y axis.

    I have the BGW reading the XML file and getting the values. all i need to know is how to return an array list or something similar to a can draw my line graph

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: BGW Array

    something like this. this is the xml i used to test it:

    <?xml version="1.0" encoding="utf-8"?>
    <Value x="10" y="10"/>
    <Value x="20" y="20"/>
    <Value x="30" y="30"/>
    <Value x="40" y="40"/>
    <Value x="50" y="50"/>
    vb Code:
    1. Public Class Form1
    3.     Dim xmlPoints() As Point
    5.     Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    6.         Dim xml As XDocument = XDocument.Load("xml.txt")
    7.         Dim points() As Point = (From node In xml...<Value> Select New Point(CInt(node.@x), CInt(node.@y))).ToArray
    9.         e.Result = points
    11.     End Sub
    13.     Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
    14.         xmlPoints = DirectCast(e.Result, Point())
    15.         Me.Invalidate()
    16.     End Sub
    18.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    19.         BackgroundWorker1.RunWorkerAsync()
    20.     End Sub
    22.     Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    23.         If xmlPoints Is Nothing Then Return
    24.         e.Graphics.DrawLines(Pens.Red, xmlPoints)
    25.     End Sub
    27. End Class

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

Survey posted by VBForums.