0
您好我有一個自定義TextEditor
自定義文本框變化背景色:的Winform時只讀
public partial class TextEditor : TextBox
{
public TextEditor() : base()
{
this.Font = new Font("Calibri", 12.0f);
this.BackColor = Color.Gainsboro;
this.BorderStyle = BorderStyle.FixedSingle;
if (this.ReadOnly)
{
this.BackColor = Color.DarkGray;
}
}
protected override void InitLayout()
{
base.InitLayout();
base.CharacterCasing = _charCasing;
//SetStyle(ControlStyles.UserPaint, true);
}
}
我想改變其屬性時ReadOnly = true
但它不工作BackGroundColor
。
任何線索?
你可以試試這個,讓我知道結果如何:'this.BackColor = System.Drawing.SystemColors.GrayText' 。 –
嘗試將if(this,ReadOnly)更改爲if(this.ReadOnly == true) – active92