Question : rotate drawstring

How do i rotate this drawstring so that it can be the vertical verbage of a graph.
1:
2:
3:
4:
5:
6:
7:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'e.Graphics.DrawLine(Pens.Red, 0, 0, 858, 514)
        e.Graphics.RotateTransform(180)
        e.Graphics.DrawString("Number of Transactions", New System.Drawing.Font("Microsoft San Serif", 15, FontStyle.Regular), Brushes.Black, 400, 250)
        'e.Graphics.DrawLine(Pens.Green, 0, 504, 857, 0)
        e.Graphics.DrawString("Time of Day", New System.Drawing.Font("Microsoft San Serif", 15, FontStyle.Regular), Brushes.Black, 400, 250)
    End Sub

Answer : rotate drawstring

Oh!...one way is to use a tall, skinny box as the layout rectangle and letting DrawString() WRAP the text for you:

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Center
        Dim rc As New Rectangle(0, 0, 20, Me.ClientRectangle.Height)
        e.Graphics.DrawString("Number of Transactions", New System.Drawing.Font("Microsoft San Serif", 15, FontStyle.Regular), Brushes.Black, rc, sf)
    End Sub

If you have small letters next to each other then you might end up with two on a line before the next letter wraps.

To ensure only ONE letter per line I think you'd have to break down and draw each letter manually with a separate call to DrawString() for each letter.  You'd have to calculate the exact position to make them align properly...  =\
Random Solutions  
 
programming4us programming4us