Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i had written the below code to rotate the text at particular point, but it is changing from screen to screen. how can i rectify it. Is there any code to fix to display the string in the Same Place irrespective of the screen..

C#
private void rotateString(Graphics g)
        {
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            g.RotateTransform(-15);  //rotate in a given angle
            g.DrawString(textCName.Text, new Font("Arial", 12), Brushes.Black, new PointF(60, 600));
            g.DrawString(textSignature.Text, new Font("Edwardian Script ITC", 12), Brushes.Black, new PointF(500, 700));
        }
Posted
Comments
BillWoodruff 11-Mar-15 7:38am    
Please clarify exactly what you mean when you "changing from screen to screen." Do you mean the rotated Text is moving with each screen refresh >?

I suggest you create your Fonts, Brushes, and PointF variable, in Form-level scope, and re-use references to them in the 'rotateString method.
Jan Bakker 11-Mar-15 9:59am    
You hard coded your rotation point and using a font size on different screens results in different size (pixels) for your text. Place the rotation point in the middle of your text using ActualWith /2.0 and ActualHeight / 2.0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900