Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Displaying Real-Time Stock Information Using Multithreading : Page 2

Learn to use multithreading to build applications whose UI remains active even while performing time-consuming or resource-intensive background tasks.

Displaying Graphs Using the Chart FX Component
After creating the Web service project, add a new Windows application project (name it "Stock Quote") to the Solution Explorer. Add a Web Reference to the Web service project created earlier. The Solution Explorer should now look like Figure 1.

To build this project, you need to download and install a 30-day trial copy of the Chart FX component from http://chartfx.com/. After installing the Chart component, you should be able to locate it in the Toolbox in Visual Studio .NET 2003 (see Figure 2).

Figure 1. The Projects in Solution Explorer: The figure shows the StockWS Web service project and the Windows Forms Stock Quote projects in the Visual Studio Solution Explorer pane.
Figure 2. The Chart Component in the Toolbox: You need to download and install a 30-day trial copy of the Chart FX component from <a href='http://chartfx.com/' target='_blank'>http://chartfx.com/</a> to get the component to appear in the Toolbox.
In the default Form1 of the Windows application, populate the form with the following controls, as shown in Figure 3:

  • Chart
  • ComboBox
  • Button
The Chart Component offers many options for customizing its behavior and look-and-feel. You can format the Chart component using the Wizard (located at the bottom of the Properties window, see Figure 4).

Figure 3. The Stock Quote Main Form: The figure shows how the default form should look after populating the form with the appropriate controls.
Figure 4. Formatting Wizard for the Chart Component: The Wizard offers numerous options for formatting the Chart Component.

The easiest way to follow the example is to copy and paste the following Chart properties into the "Windows Form Designer Generated" code region of the form in the code-behind class:

'Chart1 ' Me.Chart1.AxisX.Staggered = True Me.Chart1.AxisX.Step = 10 Me.Chart1.AxisY.Step = 10 Me.Chart1.BackObject = GradientBackground1 Me.Chart1.DataStyle = _ SoftwareFX.ChartFX.DataStyle.ReadXValues Me.Chart1.DesignTimeData = _ "C:\Program Files\ChartFX for .NET " & _ "6.2\Wizard\XYZero.txt" Me.Chart1.Gallery = SoftwareFX.ChartFX.Gallery.Lines Me.Chart1.InsideColor = _ System.Drawing.Color.Transparent Me.Chart1.LineWidth = 3 Me.Chart1.Location = New System.Drawing.Point(40, 16) Me.Chart1.MarkerShape = _ SoftwareFX.ChartFX.MarkerShape.None Me.Chart1.Name = "Chart1" Me.Chart1.NSeries = 1 Me.Chart1.NValues = 20 Me.Chart1.Palette = "HighContrast.HighContrast" Me.Chart1.PointLabels = True Me.Chart1.Size = New System.Drawing.Size(656, 216) Me.Chart1.TabIndex = 12 Me.Chart1.Titles.AddRange(New _ SoftwareFX.ChartFX.TitleDockable() _ {TitleDockable1})

Also, populate the ComboBox control with the following items: "MSFT," "SUN," "YHOO," and "GE." You can do that in the Form_Load event:

Me.cmbStocks1.Items.AddRange(New String() {"MSFT", "SUN", "YHOO", "GE"})

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.