[RESOLVED] [2005] Display Vertical Text in a label ?
I've searched for vertical text, but was unable to find an answer on how to display vertical text in a label; eventhough there is an indication that it can be done.
I tried to use the following sub but all I can get to display a emptyness.
VB Code:
Public Sub DrawYAxis()
Dim bm As Bitmap = New Bitmap(30, 50)
Dim g As Graphics = Graphics.FromImage(bm) 'Graphics object created from bitmap
Thanks. However, what I want to do is have the Y Axis displayed vertically along the Y axis of a graph. This will also be used to display other text non-horizontally. I've been searching the web, but so far no one has come close the actually showing how to do what i need (at lease I can't figure it out. What is throwing me off is trying to create a graphics object from a label. It does not have to be a label; a picturebox of panel will also work.
Thanks, francisstokes, for your help. I don't want the text to read vertically one letter at a time, but the actually be sideways, as if the page was turned. I do not have a image to show you. I want the X Axis to be view horizontally along the top of the grid, and the Y Axis to be view turned 90 degrees along the left edge of the grid.
jmcilhinney, in another thread indicated that this was posible.
Working with RotateTransform is a pain in the neck. YOu have to set the rotate before you do the drawing, and then it wacks up the X and Y coordinates, since you have to imagine them all rotated.
I made a picturebox instead of a label, and this worked..
VB Code:
Public Sub DrawYAxis()
Dim bm As Bitmap = New Bitmap(300, 500)
Dim g As Graphics = Graphics.FromImage(bm) 'Graphics object created from bitmap
Dim drawFont As New Font("Arial", 12)
Dim BlackBrush As New SolidBrush(Color.Black)
Dim What As String = "Y Axis"
g.RotateTransform(90)
'g.TranslateTransform(CSng(bm.Width / 2), CSng(bm.Height / 2)) 'I couldn't get this to work upside down because I didn't feel like playing with the math all day :)
No, it does not need to be a label. I came across this sub, I found in "Bobo Color Picker" from PSC, that I incorporated into the program. It is close to what I want, except that I can't control the faceing of the text.
VB Code:
Public Sub DrawYAxis(ByVal TargetBox As PictureBox, ByVal lblText As String)
'Printing text vertically
Dim drawFont As New Font("Arial", 10)
Dim TextBrush As New SolidBrush(System.Drawing.SystemColors.MenuText)
TargetBox.Image = New Bitmap(TargetBox.Width, TargetBox.Height)
Dim g As Graphics = Graphics.FromImage(TargetBox.Image)