Draw to a picturebox from a module

  • Thread starter Thread starter Les2011
  • Start date Start date
L

Les2011

Guest
I am trying to figure out what I am doing wrong here. I placed a picturebox onto my form1 and then opened a module and put the following code snippet in it so that when I call the module it will send the graphics over to the picturebox on my main form? Following is my code snippet.

Module Module1
Public backbuffer As New Bitmap(3000, 3000) 'overdraw my buffer

Public Sub Les()
Beep()
Dim t As String
Using g As Graphics = Graphics.FromImage(backbuffer),
f1 = New Font("Calibri", 36, FontStyle.Regular),
fmt As StringFormat = CType(StringFormat.GenericTypographic.Clone, StringFormat)
fmt.FormatFlags = fmt.FormatFlags Or StringFormatFlags.MeasureTrailingSpaces
t = "This is a test"
g.Clear(Color.White) 'paint the buffer white
g.DrawString(t, f1, New SolidBrush(Color.Black), New Point(50, 50), fmt)
End Using
Form1.TextBox1.Text = "Just a test"
End Sub
End Module

I was successful in sending text (Just a test) to a textbox on my main form but am having difficulty in sending the graphics to the picture box. BTW hey Reed how are you doing?

Les

Continue reading...
 
Back
Top