views:

365

answers:

2

How to change textbox focus color?

I am using diffrent colored textboxes. Example dark violet, but keyboard focus is black. This is bad combination. How i can change textbox focus to gain more visual contrast?

+4  A: 

A presume you're working in WPF, so try setting the FocusVisualStyle-property.

More information about this can be found at: http://msdn.microsoft.com/en-us/library/bb613567.aspx

Pbirkoff
The tag says WPF...
Peter Lillevold
+1  A: 

If for web with javascript you can do something similar to the following

Javascript

function DoBlur(fld) 
{
    fld.className='normalfld';
}

function DoFocus(fld) 
{
    fld.className = 'focusfld';
}

Your CSS would have the following

.normalfld
{
    background-color: #FFFFFF;
}
.focusfld
{
    background-color: #FFFFCC;
}

and for your text box

then your text box will have the OnFocus and OnBlur events wired up.

<input type="text" onblur="DoBlur(this);" onfocus="DoFocus(this);" /> 
Nic