The text of this article is not in this database — only its details are. Read it on the old site: Auto Redraw in VB.NET
2 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Auto Redraw in VB.NET
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
nimesh patelPosted Dec 19, 2008, 1:43 AM
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 11, 2007, 4:02 AM
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