Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference 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 January 25th, 2008, 12:54 AM
Authorized User
 
Join Date: Oct 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Click event for graphics

In the chapters 19 to 22, you have give all the graphics code for load event. Is there any way to make the same code work for the click-event?
Please give one example.


 
Old January 25th, 2008, 12:12 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think you meant the examples draw in the Paint event handler not Load.

Paint is where you generally want to draw stuff. If you draw somewhere else, such as a Click event handler, then whatever you draw disappears when the form refreshes. To try this, use CreateGraphics to make a Graphics object and then draw on that instead of the one provided by the Paint event handler.

To make changes that last, you need to create a Bitmap, make a Graphics object associated with it, draw on that, and then display the Bitmap somewhere such as in a PictureBox's Image property or the form's BackgroundImage property. For an example, see:

    http://www.vb-helper.com/howto_net_auto_redraw.html

Usually it's just easier to draw in the Paint event handler.

Rod

Rod Stephens, Visual Basic MVP
RodStephens@vb-helper.com

*** New Book ***
"Visual Basic 2008 Programmer's Reference"

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Click event being cancelled!? Abbas ASP.NET 2.0 Professional 3 July 16th, 2007 05:18 PM
Double-click event Grafixx01 Access 6 May 7th, 2007 08:09 AM
right click mouse event sen22 ASP.NET 2.0 Basics 5 December 16th, 2006 08:46 AM
click event code mohiddin52 Access VBA 1 February 14th, 2006 01:52 PM
Click Event dkr72 C# 3 December 8th, 2004 06:23 PM





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