2017-08-25 4 views
1

標準GroupBoxFlat-Sスタイルを使用します。背景色はGainsboroです。GroupBoxのボーダーは、背景色を使用するときにサーバー2016に表示されません。

それはこのようになります私のWindows 7の開発マシン上で:

Windows Server 2016

:のWindows Server 2016マシンでアプリケーションを実行するとき

Win7Example

は、しかし、それはこのようになります

罫線が消えています(見えません)。

背景色と関係があるようですが、修正方法がわかりません。ライトブルーの色を使用している場合、これはサーバー2016で発生:

othercolor

あなたたちはどんな手掛かりを持っていますか、なぜ私たちは、BG-色Gainsboroと白のボーダーを見ることができませんか?それは私がそれをテストするために、サーバ2016を持っていけない、多分BORDERCOLORのPaintイベントをオーバーライドすると、この問題を解決する

+0

ローカルまたはRDP経由でログオンしていますか? – Filburt

+0

私はローカルであり、バーチャルボックスを使用しています – Jannik

答えて

0

....どんな意味がない、ここにカスタム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); 
     } 
    } 
} 
+1

私は同様のことを試しましたが、以前と同じように100%は見えませんでした。しかし、もしこれがうまくいくなら、私はあなたに月曜日に知らせるでしょう。 :) – Jannik

関連する問題