Answered Adding a bitmap to a Panel control.

Vertraag

Member
Joined
Jan 1, 2009
Messages
10
Programming Experience
3-5
Hello,

I am currently using the following code to paint:

VB.NET:
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

        If _backBuffer Is Nothing Then
            _backBuffer = New Bitmap(Me.Panel1.Width, Me.Panel1.Height)
        End If

        Dim g As Graphics = Nothing
        If _doBuffer Then
            g = Graphics.FromImage(_backBuffer)
        Else
            g = e.Graphics
        End If

        g.Clear(Color.Black)
        g.SmoothingMode = SmoothingMode.AntiAlias

        'Draw stuff here - Example
        g.DrawLine(Pens.AliceBlue, 0, 0, 100, 100)

        If _doBuffer Then
            g.Dispose()
            e.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
        End If

    End Sub

However, I would like this to be done on a Panel control that I created, rather than the main form. How would I go about doing this?
 
Last edited:
Back
Top