/// <summary>
        /// 计算文本的宽度
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int GetStringLength(string str, int AddLength = 0)
        {
            Font f = new Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);
            Size sif = TextRenderer.MeasureText(str, f, new Size(0, 0), TextFormatFlags.NoPadding);
            return sif.Width + AddLength;
            //MessageBox.Show((sif.Width / pdi).ToString());
        }

 

相关文章:

  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案