Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Chart Success: GDI+ Graphics At Work. Part 2  »  All Is Revealed!
Chart Success: GDI+ Graphics At Work. Part 2
by Ged Mead | Published  03/16/2005 | .NET Newbie | Rating:
All Is Revealed!

Step 6:  All is Revealed!

   You may already have inserted this next code line if you elected to “try as you go”  to see your chart building up.   Just in case you didn’t, though,  this is the time and place to do so.

    It doesn’t seem much, but it’s actually a key line in the process.   This takes the Bitmap object on which you have drawn your chart and finally shows it to the user.   It does this  by assigning the Bitmap to the Image property of the PictureBox.

   '  Assign the chart drawing bitmap as the image for the picturebox
  PBBarChart.Image = bmap

  As we learned in Part 1, you should dispose of any disposable objects once they are finished with.    This code deals with that task:

        '  Dispose of drawing objects
     End Sub

  Again, if you haven't been testing the code while reading, then you will need to add the code for the button click event:

   Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
        '  Generate the Data
        '  Then Draw the Chart
    End Sub

   And there you have your first, basic but working, bar chart.

Sponsored Links