Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

Posted

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

Posted

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

Posted
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?

  • *Experts*
Posted

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;
}
}

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...