我有一个像这样的字符串:
string s = "This is my string";
我正在创建 Telerik 报告,我需要定义一个textbox
这就是我的绳子的宽度。但是,大小属性需要设置为单位(像素、点、英寸等)。如何将字符串长度转换为像素,以便设置宽度?
EDIT:我尝试获取对图形对象的引用,但这是在继承自的类中完成的Telerik.Reporting.Report
.
不使用控件或表单:
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1)))
{
SizeF size = graphics.MeasureString("Hello there", new Font("Segoe UI", 11, FontStyle.Regular, GraphicsUnit.Point));
}
或者在 VB.Net 中:
Using graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(New Bitmap(1, 1))
Dim size As SizeF = graphics.MeasureString("Hello there", New Font("Segoe UI", 11, FontStyle.Regular, GraphicsUnit.Point))
End Using
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)