[RESOLVED] [02/03] Drawn size of string
I copied code from this thread:
And, I changed it to this
Quote:
Dim g As Graphics
Dim sz As New SizeF
sz = g.MeasureString("Test String", Me.Font)
But I am getting the "Object reference not set to an instance of an object" error. I don't have much experience with the Graphics class, and I can't for the life of me figure out what to do. Simply putting new in front of Graphics doesn't work. As you can see from the link, that post used e.Graphics, but I am doing this in a different event (Mouse Up), which doesn't have e.Graphics. Any ideas?
Thanks
Re: [02/03] Drawn size of string
You call the method me.CreateGraphics like this
Code:
Dim g As Graphics
Dim sz As New SizeF
g = Me.CreateGraphics
sz = g.MeasureString("Test String", Me.Font)
Re: [02/03] Drawn size of string