C#-计算字符串的像素长度

   /// <summary>
        /// 计算字符串长度
        /// </summary>
        /// <returns>字符串长度</returns>
        private int GetMaxTextLength()
        {
            string strMax = "";
            foreach (string strText in m_cmbExportType.Items)
            {
                if (strMax.Length < strText.Length)
                    strMax = strText;
            }

            int iTextLength = (int)listView.CreateGraphics().MeasureString(strMax, this.Font).Width;
            return iTextLength;
        }

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/myh0305/archive/2008/01/03/2012387.aspx

你可能感兴趣的:(String)