Denaes Posted March 8, 2004 Posted March 8, 2004 I'm using a custom textbox to spice up my data entry forms (and reduce the code on said forms by like 80%). One thing I'm doing is disabling the textbox for when a user is reading a record and enabling the textbox when they edit a record or create a new record. But the disabled color of the textbox is nearly the same gray color as the form and is hard to read. I know I can do this by using labels to read (giving them borders and whatnot to make them look like textboxes), but I prefer not to use two componants for one job on the form and I'm just not quite there yet with developing components to create one that switches between text and label, which I think would also be a waste. Is there a property for this? A procedure I can overload to change the backcolor? Thank you for your help :cool: Quote
Denaes Posted March 8, 2004 Author Posted March 8, 2004 I can't see a way to set it directly. But I found that changing the backcolor changes the disabled color. Still, its not nice, but its a workaround Quote
fadi Posted March 9, 2004 Posted March 9, 2004 u can do something like this, create a class that inherits from textbox and override the got focus event by putting a return in it, this way whenever the control gets focus, it will reject it Quote
Denaes Posted March 9, 2004 Author Posted March 9, 2004 u can do something like this, create a class that inherits from textbox and override the got focus event by putting a return in it, this way whenever the control gets focus, it will reject it I'm trying to change the default disabled color. How is overriding the gotFocus event and putting a return in it going to to change the disabled color? Quote
*Experts* Nerseus Posted March 9, 2004 *Experts* Posted March 9, 2004 You can use the textbox's EnabledChanged event and do something like: private void textBox1_EnabledChanged(object sender, System.EventArgs e) { TextBox tb = (TextBox)sender; if(tb.Enabled) { tb.BackColor = Color.FromKnownColor(KnownColor.Window); } else { tb.BackColor = Color.Red; } } Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.