this.textBox1.ForeColor = Color.YellowGreen;
this.textBox1.BackColor = Color.Red;

解决方案 »

  1.   

    在textBox1属性Enabled=false时this.textBox1.ForeColor = Color.YellowGreen;
    不起作用
      

  2.   

    继承TextBox控件,重写OnPaint方法,自己画
    protected override void OnPaint(PaintEventArgs e)
    {
      fillbackgroup();
      drawborder();
      drawstring();
    }
      

  3.   

    textBox1属性Enabled=false时,设置字符前景色试没有作用的!
      

  4.   

    同意,需要继承TextBox控件,重写OnPaint方法
    protected override void OnPaint(PaintEventArgs e)
    {
       //code;
    }
      

  5.   

    我记得也是,在设置为Enabled=false,无法设置前景色
      

  6.   

    HelloWorldControl.cs //------------------------------------------------------------------------------
    /// <copyright from='1997' to='2001' company='Microsoft Corporation'>           
    ///    Copyright (c) Microsoft Corporation. All Rights Reserved.                
    ///       
    ///    This source code is intended only as a supplement to Microsoft
    ///    Development Tools and/or on-line documentation.  See these other
    ///    materials for detailed information regarding Microsoft code samples.
    ///
    /// </copyright>                                                                
    //------------------------------------------------------------------------------
    namespace Microsoft.Samples.WinForms.Cs.HelloWorldControl {
       using System;
       using System.Windows.Forms;
       using System.Drawing;   public class HelloWorldControl : System.Windows.Forms.Control {
       
           protected override void OnPaint(PaintEventArgs e) {           //Paint the Text property on the control
               e.Graphics.DrawString(Text, 
                                     Font, 
                                     new SolidBrush(ForeColor), 
                                     ClientRectangle);
           }
       }
    }
      

  7.   

    能不能先把enabled=true,然后设置一下,然后enabled=false,这样可行吗?
    不好意思,很笨的想法。