How to disable textbox without text going dull grey

The environment is a mobile app, using visual studio 2008, running on .net framework 3.5.  The app runs on a Symbol 9090 mobile computer.  I have text boxes on my forms such as total accumulators, that I don't want the user to be able accidentally focus on with the touch screen, i.e. if he does touch it, I want the app to completely ignore him.

I can accomplish this by setting the 'Enabled' property for that textbox to 'False'.  But the problem is that the information showing in the text box--such as grand total--becomes a dull grey.  The number in the field is no longer a dark black--like it was before I disabled it.

Note that I tried using the 'ReadOnly' property, setting it to 'True', and while it did not allow the user to enter data, it did allow them to focus on that field, placing the cursor there.  So, that did not solve it.

Any way to make the text in the disabled text box look normal--or at least something better than a dull grey?  TIA
Who is Participating?
BaleboosConnect With a Mentor Commented:
Can't change the text color in a disabled box. However, you can simply set cancel=true in the validating event with perhaps a msgbox advising the user that changing the control is a big no no. (And leave it enabled.)
Change the "Backcolor" property to a color of your liking. Disabling a control simply makes it appear in its backcolor instead of the color property.
sasllcAuthor Commented:
My BackColor on the textbox is 'Orange', and when I run the app, the color of the textbox is still bright orange, just like it was before I disabled it.  But it's the text in the orange box that's dull grey, rather than its usual dark black.

So this makes me wonder if it has to do with the 'ForeColor' somehow.  In my code, the 'Forecolor' shows a black box with 'Windows Text' to the right.  Is THAT what is actually turning a dull grey?  If so, what syntax can I use to make it stay dark black on the screen when I run the app?
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

sasllcAuthor Commented:
With 'Enabled' set to 'False', I added this line to my code:

Me.TxtGrandTot.ForeColor = Color.Black

...and it still showed as a dull grey.  Next I changed that line of code to '...Color.Green., but it still remains grey.

Is there some other parameter I can set to make the numbers appear dark black like normal?
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
If the control shows a total, the user usually does not need to edit it. Why not use a Label instead?

Or if the user need to edit in some conditions but not in others, simply disable the control but overlay it with a Label of the same size while it is disabled.
AsishRajConnect With a Mentor Commented:
this is something i use to do in my applications, haven't tried in mobile application but u can give it a go

Set the textbox's .locked property to "True"....
but the mouse can still focus or click to it.

To Prevent this from happening
you would need to disable the focus in the Got Focus event of textbox.
BaleboosCommented: locked is not the same as VB6 locked. The equivalent of VB6 locked is "readonly". Locked in refers to design, not runtime.

Author says "readonly" isn't sufficient.

Perhaps you can make it readonly and have an "onfocus" event that moves the focus to the next control in the tab order.
sasllcAuthor Commented:
On the concept of using a label rather than a textbox...for years the form has appeared to the user as in the attached file, with the totals (in the lower left) displaying nice and clear in their text boxes, black numbers against an orange background.  I'm using labels above the text boxes to describe that type of total.

In the attached file, the 'Location Total' is clear black, but the 'Grand Total' is not, because it's the textbox I had disabled in my testing.

I'd be interested in seeing an example that someone had done for accumulating totals, that's as easy to read as my label/text box approach has been.  Maybe I'll need to switch to that solution.
Jacques Bourgeois (James Burger)PresidentCommented:
You do not have to use bright colors to attract the attention. In fact, that is one of the reasons that modern applications do not use those bright colored backgrounds. If most of the form is neutral, you can attract the attention with just a dash of color here and there.

In the standard grey Windows form, with text all in black, simply set your total in blue and in bold, it will jump at the user.

And is it really necessary to attract the attention to something as a total. If the form is always used by the same users, they will know where to look for the second time they will use the application.

And standard locations might be a better way to properly design a form. Look in the work around you, the total is almost always in the lower right corner. This is where people will look intuitively for a total.

Bold and in the lower right corner is as efficient as colorful, and will give a more modern look to your applications anyway.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.