抽绳自动换行或显示全部文本 [英] Drawstring word wrap or display entire text
问题描述
这是输出我得到当我使用的DrawString。
I =史密斯,约翰二世=约翰逊,马克III =安德森,詹姆斯四世=威廉·克雷格
V =福特,他...
块引用>
页是值是float数据类型在e.PageSettings.Margins.Left;
e.Graphics.DrawString(文字,新System.Drawing.Font(宋体,8F,FontStyle.Regular) Brushes.Black,页,30);
在上面的例子中,它是
e.Graphics.DrawString(文字,新System.Drawing.Font(宋体,8F,FontStyle.Regular),Brushes.Black,页30);
我使用这个
试图格式的StringFormat =新的StringFormat();
format.FormatFlags = StringFormatFlags.FitBlackBox;
e.Graphics.DrawString(文字,新System.Drawing.Font(宋体,8F,FontStyle.Regular),Brushes.Black,页30,格式);
我要如何展开/自动换行,这样我可以拥有整个词而不是'... 在结束了吗?
I =史密斯,约翰二世=约翰逊,马克III =安德森,詹姆斯IV =威廉·克雷格
)(V =福特,亨利
块引用>
解决方案您可以通过使用自动换行一文边框。
使用的 Graphics.DrawString方法(String,字体,刷子,的RectangleF,的StringFormat)
的的RectangleF指定绘图区,它会自动将包装你的文字你。
This is the output i get when i use DrawString.
I=Smith,John II=Johnson,Mark III=Anderson,James IV=William,Craig V=Ford,He...
page is a float datatype which value is based on e.PageSettings.Margins.Left;
e.Graphics.DrawString(Text, new System.Drawing.Font("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30);
In the above example, it is
e.Graphics.DrawString(Text, new System.Drawing.Font("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30);
I tried using this
StringFormat format = new StringFormat(); format.FormatFlags = StringFormatFlags.FitBlackBox; e.Graphics.DrawString(Text, new System.Drawing.Font("Arial", 8F, FontStyle.Regular), Brushes.Black, page, 30, format);
How do i expand/word wrap so that i can have the entire words instead of '...' at the end?
I=Smith,John II=Johnson,Mark III=Anderson,James IV=William,Craig V=Ford,Henry
解决方案You can "word wrap" the text by using a bounding rectangle.
Use Graphics.DrawString Method (String, Font, Brush, RectangleF, StringFormat)
The RectangleF specifies the draw area and it will automatically "wrap" your text for you.
这篇关于抽绳自动换行或显示全部文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!