我如何获得一个字符串的字体? [英] How do I get a Font from a string?
本文介绍了我如何获得一个字符串的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在该 System.Web.UI.DataVisualization.Charting.Chart
控制字体可以通过它的姓氏指字体进行设置。我该怎么做在code相似的地方?
< ASP:表=服务器>
<传说与GT;
< ASP:联想字体=Microsoft无衬线,8.25pt,风格大胆=/>
< /传说>
< / ASP:图表>
我怎样才能做到在codebehind相似的地方?
chart.Legends [0] = .Font Font.???(\"Microsoft无衬线,8.25pt,风格=大胆)
解决方案
使用的一个构造函数上的 System.Drawing.Font
类的:
chart.Legends [0] = .Font新字体(Microsoft无衬线
8.25,
FontStyle.Bold);
请确保包括 System.Drawing中
来方便地访问所有相关项目(的FontFamily
, fontstyle的
等)。
In the the System.Web.UI.DataVisualization.Charting.Chart
control a font can be set by referring Font by it's family name. How do I do something similar in code?
<asp:Chart runat="server">
<legends>
<asp:Legend Font="Microsoft Sans Serif, 8.25pt, style=Bold"/>
</legends>
</asp:Chart>
How can I do something similar in the codebehind?
chart.Legends[0].Font = Font.???("Microsoft Sans Serif, 8.25pt, style=Bold")
解决方案
Use one of the constructors on the System.Drawing.Font
class:
chart.Legends[0].Font = new Font("Microsoft Sans Serif",
8.25,
FontStyle.Bold);
Make sure to include System.Drawing
to get easy access to all the related items (FontFamily
, FontStyle
, etc).
这篇关于我如何获得一个字符串的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文