I am working on a C# - Winforms application and attempting to set the background colour of a read-only text box like so...
txtMyBox.BackColor = Color.FromName ("Red");
This is failing with the error message...
System.ArgumentException was unhandled
Message=Control does not support transparent background colors.
Source=System.Windows.Forms
First things first; is this the right way to set the background colour for a read-only textbox? I'm doing this a lot for ordinary textboxes and it appears to work fine.
If it is, could someone help me out with what a "transparent background color" is, and why I should want one? I don't think I do; I just want the background to change colour.
Quite old post but... Have you tried this before?
public partial class MyForm : Form
{
public MyForm()
{
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With