简体   繁体   中英

How can I change the direction text flows in a drawstring?

I'm making a label printing thing for a candy shop in C#. The label printer stock is narrow and tall, like a portrait style format so I'm printing using

System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.DirectionVertical); 

to do it so the outputted label will be landscape oriented. Everything was going smoothly until I got to the point where ingredients would go. I defined a rectangle to enclose the space where it would be and it prints, but the text flows in the wrong direction. The label is designed so the "top" would be the right long edge and text flows to the left. Problem is, my drawstring text starts left and flows right. Example here:

在此处输入图片说明

What do I do to make it flow the other way? Thanks!

Nevermind, I figured it out. I changed it to System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft); and now it works perfectly :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM