VB.NET Class method handles paint event -


How do I use clause handles in my class method? For example, I want to create a picture with the code at PictureBox 1:

  Public Class Cell Public All Drawel () Handles Photo Box 1 Paint Code & Sub End Class   

I have an error:

  handles section requires an athletic variable defined in one type or its base types.   

How can I do this without using

  Private SubPicturebox 1_Paint (by-send as an object, same as the system and the system As .windows.form.pententajrgs) handles PictureBox1. Color   

ps sorry for bad english

You can create your own routine to attract on your canvas.

  Options Strict Options Option Off-Off Public Class Form1 Personal Sub Button1_Click (as the object, as E EventArgs) Handle Button1.Click Blind Canvas New Bitmap (PictureBox1.Width, PictureBox1.Height) as clear on the dim canvasGraphics as Graphics = Graphics.FromImage (Canvas) Dim CellRect new rectangle (100, 100, 100, 100) as cell.draw (canvasGraphics, cellRect, Color.Red , New Pen (New SolidBrush (Color.Green), 1)) PictureBox1 .image = Canvas End Sub Public Class Cell Public Shared Sub Scene (ByRef In the form of canvasGraphics graphics, as ByVal cellRect rectangle, ByVal fillColor color, as the ByVal borderPen Pen) Dim renderedCell new bitmap (cellRect.Width, cellRect.Height, as the system. Drawing.Imaging .PixelFormat.Format32bppArgb) dim borderRect new Rectangle (0, 0, as cellRect.Width - 1, cellRect.Height - 1) = BufferedGraphicsManager.Current context.MaximumBuffer as X BufferedGraphics reference as dim reference BufferedGraphicsContext dim bgf = New shape (cellRect.Width + 1, cellRect.Height +1) bGfx = context.Allocate (Graphics.FromImage (renderedCell), new rectangle (0, 0, cellRect.Width, cellRect.Height) in the form of slow G Graphic S = bGfx.Graphics g.Clear (fillColor) g.DrawRectangle (borderPen, borderRect) bGfx.Render () canvasGraphics.DrawImage (renderedCell, cellRect.Location) End Sub End Class End Class    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -