110,537
社区成员
发帖
与我相关
我的任务
分享
Graphics g=label1.CreateGraphics();
int n; //文本行数
int wordWidth=(int)g.MeasureString(label1.Text,label1.Font).Width; //计算文字宽度
if(wordWidth%label1.Width==0)
n=wordWidth/label1.Width;
else
n=wordWidth/label1.Width+1;
MessageBox.Show("共有:" + n.ToString());
g.Dispose();
g=null;
int height = (int)g.MeasureString(label1.Text, label1.Font, label1.Width).Height;
MessageBox.Show(height.ToString());
if(wordWidth%label1.Width==0)
n=wordWidth/label1.Width;