-
March 16th, 2003, 12:53 AM
#1
Rotating Text in .NET
Is there an easy way to rotate text in VB .NET? I've searched the other forums and found some solutions, but everytime I use a solution that involves API calls, etc. I almost always end up finding an easier way to do it in VB .NET. I'm hoping to avoid implementing more than I have to. I just want to print rotated text in a picturebox. Thanks!
Jerry
-
March 17th, 2003, 09:20 AM
#2
Code:
' This example shows how to draw rotated text on a label control.
Private Sub Label_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
' Create a new font object to be used by the DrawString method
Dim NewFont As New Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point)
' Get a handle to the graphics object of the label
Dim g As Graphics = e.Graphics
' Do the transformation
g.TranslateTransform(0, 150)
g.RotateTransform(-90)
' Draw the text
g.DrawString("Rotated text", NewFont, Brushes.Blue, 0, 0)
' Reset the transform so subsequent drawing wont be affected
g.ResetTransform()
End Sub
-
March 17th, 2003, 01:49 PM
#3
Thanks! I'll play with that and see if it does what I need. I knew there had to be an easy way to do this. I'm really starting to like VB .NET.
Jerry
-
March 18th, 2003, 06:24 PM
#4
Alright... Played with that and got it do just what I wanted as far as rotating the text. The next trick:
Make the text a little transparent.
Any thoughts on how to adjust the opacity of the text that is drawn so you can see the image through the text? Thanks!
Jerry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|