CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    142

    adding text in picture

    i want to add text on the picture
    i have three forms
    form1 for opening picture
    form2 for displaying and this contains one picturebox
    form3 for add text
    form3 has a button and a text field
    i enter the text in text field and press the button but text is not added
    code for adding text
    Code:
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            Dim addText As String
            addText = txtAdd.Text
            Form2.PictureBox1.CreateGraphics.DrawString(addText, New Font("Arial", FontStyle.Bold), Brushes.Black, 10, 25)
            Form2.PictureBox1.Refresh()
            Me.Close()
        End Sub
    plz tell me where i m wrong
    see the attachment also
    thanks
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: adding text in picture

    Do what you need to do in the PAINT() event of the control, and when you want it to happen, call control.Invalidate (which will call Paint)

    You'd load the picture if the text was blank, or add the text on top of the picture after it was loaded.)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured