ベースパネルから継承したパネルには、どこで使用されていても固定のBackColor
が必要です。 BackColor
は、例えば、フォームのDesigner.cs
ファイルに設定されていないコントロールのBackColorが変更されないようにするにはどうすればよいですか?
public class MyPanel
{
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = Color.Red;
}
}
}
:私のベースパネルは、次のようになります
this.sampleControl.Font = new System.Drawing.Font("Tahoma", 8.25F,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.sampleControl.Location = new System.Drawing.Point(0, 0);
this.sampleControl.Margin = new System.Windows.Forms.Padding(5);
this.sampleControl.Name = "sampleControl";
this.sampleControl.Padding = new System.Windows.Forms.Padding(2, 0, 2, 2);
this.sampleControl.Size = new System.Drawing.Size(230, 100);
this.sampleControl.TabIndex = 1;
は実際にはどこにでも設定は色はありませんが、私はそれは何とかなると仮定しますそれが配置されているパネルのプロパティ。これをどうやって防ぐことができますか?
あなたが見る実際の色は何ですか? – ken2k
親コントロールの背景色、つまり親パネルが青色の場合、このコントロールも青色になります。 – xsl