VS 2008: Writing text on Windows form

Anybody knows how to write text on Winform without any controls on it?
Thanks.
quasar_eeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
PaulHewsConnect With a Mentor Commented:
You can position the text using the Y position... Use FontHeight to approximate the height of the new line.

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        For i As Integer = 0 To 9
            e.Graphics.DrawString("This is a test", Me.Font, Brushes.Blue, 10, 10 + i * Me.FontHeight)
        Next
    End Sub
0
 
PaulHewsCommented:
In the Form_Paint event:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    e.Graphics.DrawString("This is a test", Me.Font, Brushes.Blue, 10, 10)
End Sub

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
quasar_eeAuthor Commented:
Making this code work. Do you think there might be easier way to accomplish this? I believe forms Text property in older versions of Visual Studio allowed to accomplish it . It displays text in the form caption now instead.
0
 
PaulHewsCommented:
>I believe forms Text property in older versions of Visual Studio allowed to accomplish it . It displays text in the form caption now instead.

No.  In VB6, one could use the Print method to put text on a form... That method does not exist in the .NET framework, so GDI+ or using a label or other control is the only way.

0
 
quasar_eeAuthor Commented:
PaulHews, your code works. Thanks.
Do you know by chance how to write on the new line?
0
All Courses

From novice to tech pro — start learning today.