Wrox Programmer Forums
|
BOOK: Stephens' Visual Basic Programming 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' Visual Basic Programming 24-Hour Trainer by Rod Stephens; ISBN: 978-0-470-94335-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' Visual Basic Programming 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2011, 10:35 PM
Authorized User
 
Join Date: May 2011
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default Ex 33-2 Printing a Bar Chart

I finished Ex 33-2, Printing a Bar Chart. Of course, I just HAD to play with it. I filled the bars with colors, a different color for each bar. I tried creating an array with the brush names in it so I could add 1 line to the loop but Visual Studio balked at that and gave me "Value of type 'String' cannot be converted to 'System.Drawing.Brush'.". I ended up using a Select statement inside the loop. Is there a way to build the Brushes.color portion of the command line? I can "build" coordinates, font names and string values ... why can't I build the Brushes.color portion? I even tried creating an array as New SystemBrushes, but that didn't work either. Thank you.

Keith Z.
 
Old October 27th, 2011, 10:56 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Keith,

An excellent idea!

There are ways you can convert things like color names into colors and then use them to make brushes, but it's a lot easier to just make an array of brushes. For example:

Code:
Dim bar_brushes() As Brush =
{
    Brushes.Red,
    Brushes.Green,
    Brushes.Blue,
    Brushes.Orange
}
Then you can use one of the brushes directly as in:

Code:
e.Graphics.FillRectangle(bar_brushes(2), Me.ClientRectangle)
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
zavodney (October 27th, 2011)
 
Old October 27th, 2011, 11:07 AM
Authorized User
 
Join Date: May 2011
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

That's what I was trying to do. I just couldn't find the right way. Thank you.

Keith Z.
 
Old October 27th, 2011, 11:24 AM
Authorized User
 
Join Date: May 2011
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

It works fine. Thank you.

Keith Z.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Bar Chart Properties Neal Crystal Reports 0 May 25th, 2007 05:04 AM
Bar Chart eilob C# 1 May 20th, 2007 09:48 PM
Bar Chart Problem.? megana Crystal Reports 0 July 21st, 2006 02:53 PM
Bar Chart with Item names beside bar jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 23rd, 2004 01:05 PM
Drill Down from Bar Chart to another chart snowbird Crystal Reports 0 July 11th, 2003 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.