Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 26th, 2011, 10:35 PM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
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.
Reply With Quote
  #2 (permalink)  
Old October 27th, 2011, 10:56 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,149, Level: 23
Points: 3,149, Level: 23 Points: 3,149, Level: 23 Points: 3,149, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 642
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!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
zavodney (October 27th, 2011)
  #3 (permalink)  
Old October 27th, 2011, 11:07 AM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
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.
Reply With Quote
  #4 (permalink)  
Old October 27th, 2011, 11:24 AM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

It works fine. Thank you.

Keith Z.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 07:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.