c# groupBox 带标题边框,标题居中

private void groupBox1_Paint(object sender, PaintEventArgs e)
        {
            //e.Graphics.Clear(Color.Transparent);            
            //SizeF fontSize = e.Graphics.MeasureString(groupBox1.Text, groupBox1.Font);
            //e.Graphics.DrawString(groupBox1.Text, groupBox1.Font, Brushes.Blue, (groupBox1.Width - fontSize.Width) / 2, 1);
            //e.Graphics.DrawLine(Pens.CornflowerBlue, 1, 7, (groupBox1.Width - fontSize.Width) / 2, 7);
            //e.Graphics.DrawLine(Pens.CornflowerBlue, (groupBox1.Width + fontSize.Width) / 2 - 4, 7, groupBox1.Width - 2, 7);


            //e.Graphics.DrawLine(Pens.CornflowerBlue, 1, 7, 1, groupBox1.Height - 2);
            //e.Graphics.DrawLine(Pens.CornflowerBlue, 1, groupBox1.Height - 2, groupBox1.Width - 2, groupBox1.Height - 2);
            //e.Graphics.DrawLine(Pens.CornflowerBlue, groupBox1.Width - 2, 7, groupBox1.Width - 2, groupBox1.Height - 2);
        }

猜你喜欢

转载自blog.csdn.net/qq_32425273/article/details/80607870