Auto Redraw in VB.NET
This is a problem if you wish to display text and graphics directly on a form. This brief project should help to provide you with AutoRedraw capability.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Auto Redraw in VB.NET

nimesh patelPosted Dec 18, 2008, 8:43 PM EST
hi.. I want to display a image in a picturebox and then i want to draw a shapes on that image , after that l can able to move that drawn shapes, for that what i have to do.. Give me in detail. Thanks in advance , for give me reply
John WeinholdPosted Feb 10, 2007, 11:02 PM EST
The key to AutoRedraw is to use a control with an image property. A form doesn't have an image property. This article provides a persistent bitmap (b1) that is drawn on the form. If you use a control with an image property and initialize the image with a bitmap, the image will persist. Equivalent code for the article is here: Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Size and describe the form Width = 200 Height = 150 Text = "AutoRedraw" 'Size, Locate, & Describe the button With Button1 .Left = 30 .Top = 80 .Width = 100 .Height = 20 .Text = "PrintSomething" .BringToFront() End With 'Size, Locate, & Describe the ControlWithImage With ControlWithImage .Left = 0 .Top = 0 .Width = Width .Height = Height 'Load a persistent bitmap into the ControlWithImage .Image = New Bitmap(Width, Height) End With 'Print beginning text ControlWithImagePrint("Beginning Text", 25, 10) End Sub 'Print something Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ControlWithImagePrint("Something", 35, 46) End Sub Private Sub ControlWithImagePrint(ByVal t$, ByVal x1%, ByVal y1%) Dim g1 As Graphics g1 = Graphics.FromImage(ControlWithImage.Image) g1.DrawString(t, New Font("Verdana", 12), Brushes.Black, x1, y1) ControlWithImage.Invalidate() g1.Dispose() End Sub End Class