我沒有服務器2016年測試它,但也許重寫Paint
事件BORDERCOLOR將解決這個問題,這裏是一個自定義GroupBox
控制,你可以改變顏色borderColor
在構造函數中。
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CustomGroupBox gb = new CustomGroupBox();
gb.Location = new Point(5, 5);
gb.Size = new Size(200, 100);
this.Controls.Add(gb);
}
}
public class CustomGroupBox : GroupBox
{
private Color borderColor;
public Color BorderColor
{
get { return this.borderColor; }
set { this.borderColor = value; }
}
public CustomGroupBox()
{
this.borderColor = Color.Red;
}
protected override void OnPaint(PaintEventArgs e)
{
Size tSize = TextRenderer.MeasureText(this.Text, this.Font);
Rectangle borderRect = e.ClipRectangle;
borderRect.Y += tSize.Height/2;
borderRect.Height -= tSize.Height/2;
ControlPaint.DrawBorder(e.Graphics, borderRect, this.borderColor, ButtonBorderStyle.Solid);
Rectangle textRect = e.ClipRectangle;
textRect.X += 6;
textRect.Width = tSize.Width;
textRect.Height = tSize.Height;
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), textRect);
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), textRect);
}
}
}
您是本地登錄還是通過RDP登錄? – Filburt
我是本地人,使用虛擬方塊 – Jannik