Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old June 6th, 2011, 12:39 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 Lesson 6 Try It

After finishing the Lesson 6 Try It I decided to add 2 more features. When I changed the text color I changed the 'A' icon of the drop down button on the tool bar. That worked fine. I then tried to change the image of the background color drop down button on the tool bar. That did not work well. While working on the lesson I imported them from your downloaded code. Unfortunately they all are listed as 'System.Drawing.Bitmap'. I have the .bmp files listed in my Solution Explorer window and I can open them and see the icon. How do I change the icon on the tool bar to indicate the current background color?? I know it is redundant, but I just wanted to do it (I was playing and having fun). Thank you.

Keith Z.
  #2 (permalink)  
Old June 6th, 2011, 04:15 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Keith,

I'm guessing you used code similar to the following to set the foreground color item's color:

Code:
btnTextColor.ForeColor = Color.Green
To set the background button's image, use code similar to the following:

Code:
btnBackgroundColor.Image = My.Resources.Green
The My namespace is covered briefly in Lesson 36 so you're getting a bit ahead but in a nutshell My contains shortcuts to useful items including project resources. In this case, the project includes files named Blue.bmp, Green.bmp, etc. so by default it gets resources holding the corresponding images named Blue, Green, etc.

The line of code above sets the button's Image property to the Green resource so you see the corresponding bitmap.

Quote:
I know it is redundant, but I just wanted to do it (I was playing and having fun).
That's an excellent way to learn this stuff! Think of changes you'd like to make and then try to make them.

Let me know if you have other questions or have trouble getting the images to work.

(Also post a review when you have a chance!)
__________________
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 (June 6th, 2011)
  #3 (permalink)  
Old June 6th, 2011, 10:07 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
Smile Thanks

My background icon is changing now, thank you. Yes, that is the code I used to change the text button icon.

Keith Z.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 5 exercises. thelemur BOOK: Java Programming 24-Hour Trainer by Yakov Fain 9 March 29th, 2013 11:56 PM
Lesson 2 - can not create Class BubNorth BOOK: Java Programming 24-Hour Trainer by Yakov Fain 1 March 4th, 2012 09:44 PM
Lesson 19B-Displaying Data in MVC Cybermaniac BOOK: ASP.NET 4 24-Hour Trainer 3 January 31st, 2012 08:16 AM
Lesson 3 question soneal777 BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 1 August 30th, 2010 06:17 PM
Lesson on Event Calendar - Chapter 14 Mike Smith BOOK: Professional C#, 2nd and 3rd Editions 6 April 6th, 2004 03:03 PM





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