drawstring alike

G

Geert Gerrits

Hi,

I'm trying to print a string under an angle. Is there a way to do this ?

Thanks.
 
J

John Baro

What do you mean "under an angle"?
If you mean.
/______
85

Then you can use the graphics object passed in the paint event to paint the
angle and then draw the string underneath.
Have a look at the Graphics class.
HTH
JB
 
N

nnayak

Heres some quick code I churned up.
Hope you get the idea.

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
StringFormat oStringFormat = new StringFormat();
oStringFormat.Alignment = StringAlignment.Center;
g.DrawString("Test",
new Font("Arial", 20),
new SolidBrush(Color.Red),
150,100,oStringFormat);

g.RotateTransform(45);
g.TranslateTransform(50,-100);
g.DrawString("Test",
new Font("Arial", 20),
new SolidBrush(Color.Red),
150,100,oStringFormat);
g.ResetTransform();
g.DrawString("Test",
new Font("Arial", 20),
new SolidBrush(Color.Blue),
200,100,oStringFormat);
}

Cheers
Nitya.
 
B

Bob Powell [MVP]

The GDI+ FAQ has an article on this subject

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*

The GDI+ FAQ: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41

*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*
 
C

cody

I'm trying to print a string under an angle. Is there a way to do this ?


Simply rotate the Transformation matrix of the Graphics object and all
objects are drawn with you specified angle.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top