//直接使用窗体的字体对象 Font f = new Font("SimSun", 7F, System.Drawing.FontStyle.Regular); Size size = TextRenderer.MeasureText("Test测试文字", f); //得到字的宽度 size.Width;
Winform获取文字的宽度
于 2023-09-21 17:43:08 首次发布
//直接使用窗体的字体对象 Font f = new Font("SimSun", 7F, System.Drawing.FontStyle.Regular); Size size = TextRenderer.MeasureText("Test测试文字", f); //得到字的宽度 size.Width;