tags:

views:

259

answers:

4

Hi im having a few problems rotating a string, i found that you need graphics.rotate() but when i change the rotation, i cannot even see the string. It appears the pivot point has completely thrown me. Also i saw an example with transform but i decided i did not need this?

If my string was a graph label, reading top to bottom and i needed to rotate it 180 degrees so that it read bottom to top, how would i do this?

Thanks in advance

A: 

Maybe try rotating only a few degrees to start with and see where the graphics are starting to shift? The 180 might be making it render "off screen".

uosɐſ
+1  A: 

The graphics.Rotate(180) method uses the location as pivot point. So basically, your string is thrown off the clip and is not rendered at it's supposed location. If you're only rendering this string in the clip, it should be easy enough to replace at the right location.

Here's a temporary solution, assuming you're drawing inside a picture box and you're only rendering the string inside of it.

g.TranslateTransform(pictureBox1.Width, pictureBox1.Height);
g.RotateTransform(180);
Moox
A: 

A string is a data type, like for a variable. I assume you mean you want to rotate text displayed on a Form or Webpage. What type of application is it?

Also, please specify in what type of control the string is displayed... textbox, label, gridview...

Lily
I don't think there's much confusion here as to what he's asking. Also, the answer to the question does not depend on what type of control is being displayed.
uosɐſ
A: 

If you are using Win32/GDI/GDI+ then see my answer to this question:

http://stackoverflow.com/questions/2250437/how-to-draw-vertical-text-in-windows-gui

If you are using HTML or some other web based solution then these might help:

http://stackoverflow.com/search?q=vertical+text

If you do not mean vertical text and do in fact really mean a rotated string then you need to use a transform and drawstring.

Graphics.RotateTransform(90);               
Graphics.DrawString("123456", this.Font, new SolidBrush(Color.Black), 0, 0);

Of course you may need a translation transform to bring the text back into view.