Changing control rectangle color?
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
Well, I haven't done that but I must ask, why not use an error provider? Just find the Error Provider[^] in your toolbox and drop one on your form. Then you can use something like this to set the error when they click 'check'.
myErrorProvider.SetError(myTextBox, "Not Valid");
If at first you don't succeed ... post it on The Code Project and Pray.
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
See
TextBox.BackColor
[^]. You may also want to consider using theErrorProvider
[^] class. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
Another possibility is to place an asterisk (
*
) in the text or color the boxes when the form is populated. Then in theValidating
event, change the color, etc. if the result is valid. The color can be changed by setting theBackColor
property, but you may need to refresh orInvalidate()
the control to see the change.CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
if it is a website, I would do this in client side code instead of server code. (saves a round trip to the server) Add a validation function that is called on the onchange event for that control that will do some basic checking (empty fields, phone number formatting, etc...) and color the control accordingly. Alternatively you can skip the onchange event and put the validation when the form is submitted.
V.
-
You know how some website login forms change the color of textboxes you left empty to red? I want to do that in my application. Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red. I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
It's not a website, it's a windows forms app. I'm currently changing the backcolor to red and forecolor to white (when you change the text, the color also changes back to normal) but that looks kinda awkward. If possible I'd like to use the more elegant way of just coloring the frame of the textbox/drawing a frame around it. How does the blinking look? It's quite possible that there'd be like 5 textboxes on a form which require input and all of them blinking at the same time would probably weird and confusing. I want a simple, yet obvious visual hint that there is something wrong.
-
It's not a website, it's a windows forms app. I'm currently changing the backcolor to red and forecolor to white (when you change the text, the color also changes back to normal) but that looks kinda awkward. If possible I'd like to use the more elegant way of just coloring the frame of the textbox/drawing a frame around it. How does the blinking look? It's quite possible that there'd be like 5 textboxes on a form which require input and all of them blinking at the same time would probably weird and confusing. I want a simple, yet obvious visual hint that there is something wrong.
Then use the ErrorProvider, just run some tests. The ErrorProvider, see my previous reply, is a windows forms control so i dont really understand the
Megidolaon wrote:
It's not a website, it's a windows forms app.
comment :^)
If at first you don't succeed ... post it on The Code Project and Pray.