March 15th, 2003, 11:53 PM
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!
March 17th, 2003, 08:20 AM
' 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
' Draw the text
g.DrawString("Rotated text", NewFont, Brushes.Blue, 0, 0)
' Reset the transform so subsequent drawing wont be affected
March 17th, 2003, 12:49 PM
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.
March 18th, 2003, 05:24 PM
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!
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.