vs

 //窗体标题居中

Graphics g = this.CreateGraphics();

                Double startingPoint = (this.Width / 2) - (g.MeasureString(this.Text.Trim(), this.Font).Width / 2);
                Double ws = g.MeasureString("*"this.Font).Width;
                String tmp = " ";
                Double tw = 0;
 
                while ((tw + ws) < startingPoint)
                {
                    tmp += "1 ";
                    tw += ws;
                }
                this.Text = tmp.Replace("1"" ") + this.Text.Trim();
posted @ 2020-05-01 13:42  theyounggg  阅读(688)  评论(0)    收藏  举报