Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Rotating text around it's axis with GDI+

Posted on 2004-08-26
1
Medium Priority
?
529 Views
Last Modified: 2009-07-29
I'd like to know how to rotate a string around it's center/middle axis.  (Presumably using Graphic.RotateTransform) I have looked at the TranslateTransform method, but I cannot figure out how to use it properly.

 I would be extremely thankful for any assistance in this endavour.

0
Comment
Question by:mjohansson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
iboutchkine earned 2000 total points
ID: 11911772
Try this
 Dim angle As Integer
 Dim f As Font = New Font("Arial", 10)
Dim s As String = "Test String"

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        angle = CType(TextBox1.Text, Integer)'enter the angle to TextBox1
        Me.Refresh()' to repaint the form

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim sz As Size = Me.Size
       'find the middle of the form
        Dim Middle As Point = New Point(sz.Width / 2, sz.Height / 2)
        e.Graphics.TranslateTransform(Middle.X, Middle.Y)

        'rotate
        e.Graphics.RotateTransform(angle)
        ' Create a new StringFormat object to
        Dim format As StringFormat = New StringFormat(StringFormatFlags.NoClip)
        format.Alignment = StringAlignment.Center
        format.LineAlignment = StringAlignment.Center
        e.Graphics.DrawString("A simple TextString ", f, Brushes.Black, 0, 0, format)

    End Sub

=======another========
 Private Sub Form1_Paint( _
        ByVal sender As Object, _
        ByVal e As System.Windows.Forms.PaintEventArgs _
    ) Handles MyBase.Paint
        e.Graphics.RotateTransform(20)
        e.Graphics.DrawString("Hello World!", Me.Font, Brushes.Blue, 0, 0)
    End Sub
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question