ByVal e As System.Windows.Forms.PaintEventArgs

Hi

we are working in a pocket PC application compact framework 1.0(vb.net) .

We have subclass the class Picturebox to form a class IpicBox as shown below

The event pbxpaint is handled by an event handler pbx_Paint that draws text on the picturebox by calling the drawLabel method.

Private Sub pbx_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)

gxOff = e.Graphics

Dim g As Graphics = e.Graphics

If flag = True Then

lblPag1.Text = "hello"

End If

DrawLabel(lblPag1, g)

End Sub

Public Class IPicBox

Inherits System.Windows.Forms.PictureBox

Public Event pbxPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)

End Class

This picturebox is on a panel in the form . we also have two buttons below the panel on the form. On the click of the button the text drawn on the picturebox using the DrawLabel method should change . This will happen only if the event pbxPaint is raised .

Private Sub BtnNextHandler(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

RaiseEvent pbxPaint(Me, e)

End Sub

'e' here is System.EventArgs where as we need to pass 'e' as System.Windows.Forms.PaintEventArgs .

How can this be achieved



Answer this question

ByVal e As System.Windows.Forms.PaintEventArgs

  • Anon

    The correct way to force the OnPain event is to call Invalidate on your control.
  • ByVal e As System.Windows.Forms.PaintEventArgs