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
        g.Dispose()
        LinePen.Dispose()
        BarBrush.Dispose()
        ValueFont.Dispose()
        TextFont.Dispose()
     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
        GetData()
        '  Then Draw the Chart
        DrawChart()
    End Sub

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

Comments    Submit Comment

Comment #1  (Posted by an unknown user on 03/14/2005)
Rating
Part one is very good.

Where is part two?
 
Comment #2  (Posted by Ged Mead on 03/16/2005)
Rating
Slight technical hitch there :-}
Part 2 now published. Hope you find it useful.
 
Comment #3  (Posted by an unknown user on 04/18/2005)
Rating
Great Article!
 
Comment #4  (Posted by an unknown user on 05/01/2005)
Rating
Keep up the great work.. I'm at Virginia Tech (Go Hokies).. doing my montrous VB.net final project and this has helped me a bit. Thank you so much. You might wanna add a small blurb for newbies to know how to change the scale. Other than that...A++

 
Comment #5  (Posted by Ged Mead on 05/01/2005)
Rating
Thanks - Scaling will be included in the upcoming Part 4 of the series (Back to the Bar). Also 3D bars and multiple colors.
 
Comment #6  (Posted by an unknown user on 06/15/2005)
Rating
This walk-through is absolutely perfect. I've been looking to draw a simple chart on my project for weeks now, and this was the ONLY comprehensive explaination I've found! Thank You!!!
 
Comment #7  (Posted by an unknown user on 06/15/2005)
Rating
This walk-through is absolutely perfect. I've been looking to draw a simple chart on my project for weeks now, and this was the ONLY comprehensive explaination I've found! Thank You!!!
 
Comment #8  (Posted by an unknown user on 07/26/2005)
Rating
Ged, I can't thank you enough for taking the time to make something like this available to the on-line community. I am in the process of teaching my self vb.net and your tutorial has taught me far more then I ever expected to learn. Once again many thanks!
 
Comment #9  (Posted by an unknown user on 12/08/2005)
Rating
Clearly explained.
 
Comment #10  (Posted by an unknown user on 01/18/2006)
Rating
This is really very nice article explained in a detailed way..

Thanks for providing such a great article.
 
Comment #11  (Posted by an unknown user on 01/30/2006)
Rating
excellent learning tutorial on working with graphics. Explanations for each steps great.
 
Comment #12  (Posted by an unknown user on 02/07/2006)
Rating
Superb article !! helped me a lot in my project
 
Comment #13  (Posted by Samer on 07/01/2006)
Rating
Thanks for ALL the articles. They helped me alot. Can you please write an article about drawing objects (Lines, Rectangles, Circles, ...etc) and then using the mouse to select the object and change their attributes (color, size, position, delete...etc)
 
Comment #14  (Posted by Ankur Adarsh on 07/31/2006)
Rating
this is good but i do not understand how to use picture box in web programming, because i can not see picture box control in web form.
 
Comment #15  (Posted by an unknown user on 10/19/2006)
Rating
Very good article. Prakash Bajaj
 
Comment #16  (Posted by Roy Oliver on 12/04/2006)
Rating
Thanks for the lessons Ged. Knowing how to manipulate graphics was the only thing missing from my skill set.
 
Comment #17  (Posted by an unknown user on 01/20/2007)
Rating
hey dude i love this and i'm going to pass my visual basic test with flying colours..love you keep going dude
 
Comment #18  (Posted by an unknown user on 08/24/2007)
Rating
very simple
 
Comment #19  (Posted by an unknown user on 01/03/2008)
Rating
thank you so much. i need it very much.
 
Comment #20  (Posted by shohreh on 01/03/2008)
Rating
it was excellent.
 
Sponsored Links