Results 1 to 3 of 3

Thread: [RESOLVED] [02/03] Drawn size of string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Resolved [RESOLVED] [02/03] Drawn size of string

    I copied code from this thread:


    And, I changed it to this
    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
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    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)
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [02/03] Drawn size of string

    Thanks. That worked.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width