none
Draw text on a graphics object RRS feed

  • Question

  •  Trying to draw a line of text at certain points on a graph.  It keeps putting on the screen "System.__ComObject" and not s or "Hello there."

     

    Dim gphFormGraphics As Graphics = Me.CreateGraphics
    Dim recDrawingRectangle As Rectangle = New Rectangle(0, 0, 700, 700)
    Dim x1, y1 as Integer
    Dim
    pt1 As Point
    Dim s as string
    s="Hello There."
    x1=100
    y1=50
    pt1 = New Point(x1, y1)
    Dim
    fntText = New Font("Times New Roman", 8, FontStyle.Regular)
    gphFormGraphics.DrawString(s, fntText, Brushes.Maroon, pt1)

    Where am I going wrong?

    Sunday, November 16, 2008 8:40 PM

Answers

  • Put "Option Strict On" and you won't have these kinds of problems.  Plus you'll learn better programming practices.

    • Edited by JohnWein Sunday, November 16, 2008 10:17 PM
    • Marked as answer by Philosophaie Monday, November 17, 2008 12:16 AM
    Sunday, November 16, 2008 10:16 PM

All replies

  •  Dim gphFormGraphics As Graphics = Me.CreateGraphics 
            Dim recDrawingRectangle As Rectangle = New Rectangle(0, 0, 700, 700) 
            Dim pt1 As Point, x1 As Integer, y1 As Integer 
            Dim s As String 
            s = "Hello There." 
            x1 = 100 
            y1 = 50 
            pt1 = New Point(x1, y1) 
            Dim fntText As Font = New Font("Times New Roman", 8, FontStyle.Regular) 
     
            gphFormGraphics.DrawString(s, fntText, Brushes.Maroon, pt1) 


    Let's Program.. , Yam Sapkota
    • Proposed as answer by _-Steve-_ Sunday, October 18, 2009 11:39 PM
    Sunday, November 16, 2008 9:59 PM
  • Put "Option Strict On" and you won't have these kinds of problems.  Plus you'll learn better programming practices.

    • Edited by JohnWein Sunday, November 16, 2008 10:17 PM
    • Marked as answer by Philosophaie Monday, November 17, 2008 12:16 AM
    Sunday, November 16, 2008 10:16 PM