Hey all i have the following code that works just fine when my form loads up:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim custFont As New PrivateFontCollection()
Dim solidBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
Dim string2 As String = "AntiAlias"
custFont.AddFontFile("C:\aFont.ttf")
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias
e.Graphics.DrawString(string2, New Font(custFont.Families(0), 100, FontStyle.Regular, GraphicsUnit.Pixel), solidBrush, New PointF(10, 60))
End Sub
However, i need a way to update that font text whenever i push a button(s) on the form itself. I tried making a sub like so:
Public Sub changeText(ByVal e As System.Windows.Forms.PaintEventArgs, ByVal theText as string)
Dim custFont As New PrivateFontCollection()
Dim solidBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
custFont.AddFontFile("C:\aFont.ttf")
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias
e.Graphics.DrawString(theText, New Font(custFont.Families(0), 100, FontStyle.Regular, GraphicsUnit.Pixel), solidBrush, New PointF(10, 60))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
changeText(Me.OnPaint, "just a test")
End Sub
But i end up having an error:
Overload resolution failed because no accessible 'OnPaint' accepts this number of arguments.
on line: changeText(Me.OnPaint, "just a test")
Any help would be great! Thanks!