0

i am going to ask the same thing like other topic which I have seen.

When i use the Textbox.Enable or Textbox.readOnly, the textbox gets a dark colour, how can i change this colour for a better colour? (white could be better).

user2698690
  • 11
  • 1
  • 1
  • 3
  • 8
    If you've seen the same question before, why ask it again? What were the answers to the duplicate questions? – Jon Skeet Aug 20 '13 at 06:07

2 Answers2

1

When a TextBox is disabled, it ignores the ForeColor. You can override this by implementing your custom painting.

From the source Thread:-

You can override the OnPaint event like something like this:-

protected override void OnPaint(PaintEventArgs e)
{
     SolidBrush drawBrush = new SolidBrush(ForeColor);
     // Draw string to screen.
     e.Graphics.DrawString(Text, Font, drawBrush, 0f,0f); 
}
set the ControlStyles to "UserPaint"

public MyTextBox()//constructor
{
     // This call is required by the Windows.Forms Form Designer.
     this.SetStyle(ControlStyles.UserPaint,true);

     InitializeComponent();

     // TODO: Add any initialization after the InitForm call
}
Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

Override OnPaint method by customizing the textbox.
Also, you could see this : How to change the font color of a disabled TextBox?

Lari
  • 800
  • 7
  • 18
Vijay Hulmani
  • 969
  • 8
  • 17