Fail Uppercase?
-
i put this code in textbox_textchanged and textbox_editvaluechanged, both didn't work. yes i'm new in C#, but i think this is so simple. is this a problem in threading
string uppercase = this.txtLicense.Text.ToUpper();
this.txtLicense.Text = uppercase;i'm not sure i need to create a new thread just to force a textbox uppercase. :doh:
Midnight Ahri wrote:
is this a problem in threading
No it is not a problem with threading unless you did not reveal all of the information.
Midnight Ahri wrote:
both didn't work
"didn't work" does not tell us anything about the problem that you are having. You should know this by now.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
i put this code in textbox_textchanged and textbox_editvaluechanged, both didn't work. yes i'm new in C#, but i think this is so simple. is this a problem in threading
string uppercase = this.txtLicense.Text.ToUpper();
this.txtLicense.Text = uppercase;i'm not sure i need to create a new thread just to force a textbox uppercase. :doh:
You need to use LostFocus event to do the same.
Thanks -Amit Gajjar (MinterProject)
-
You need to use LostFocus event to do the same.
Thanks -Amit Gajjar (MinterProject)
well, thank you very much for trying. i realize it's not that hard to answer this, character casing properties fix my problem. :-\ modify : "i'm not sure i need to create a new thread just to force a textbox uppercase." thank you for the reply, but i'm sure you understand it. don't worry, next time i will write it more detail.
-
i put this code in textbox_textchanged and textbox_editvaluechanged, both didn't work. yes i'm new in C#, but i think this is so simple. is this a problem in threading
string uppercase = this.txtLicense.Text.ToUpper();
this.txtLicense.Text = uppercase;i'm not sure i need to create a new thread just to force a textbox uppercase. :doh:
Midnight Ahri wrote:
this.txtLicense.Text = uppercase;
What does this line do, besides the obvious things? Well, it sets the value of a textbox. ..which means that the value has changed. If the value changes, the Framework will trigger the "textbox_textchanged" event. So, we execute that code - which tells us to change the value again. (See a pattern?)
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
Midnight Ahri wrote:
this.txtLicense.Text = uppercase;
What does this line do, besides the obvious things? Well, it sets the value of a textbox. ..which means that the value has changed. If the value changes, the Framework will trigger the "textbox_textchanged" event. So, we execute that code - which tells us to change the value again. (See a pattern?)
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
i put this code in textbox_textchanged and textbox_editvaluechanged, both didn't work. yes i'm new in C#, but i think this is so simple. is this a problem in threading
string uppercase = this.txtLicense.Text.ToUpper();
this.txtLicense.Text = uppercase;i'm not sure i need to create a new thread just to force a textbox uppercase. :doh:
-
-
It should, at least for the TextChanged event (the clue's in the name!), but I haven't actually tested it right now.
BobJanova wrote:
It should, at least for the TextChanged event (the clue's in the name!)
The times that I programmed against a intID where the clue in the name was erroneous.. You are right, I decompiled the TextBox, which points to TextBoxBase, which has this in the setter implementation;
this.has\_been\_focused = false; if (value == this.Text) { return; }
(Śtill untested)
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
i put this code in textbox_textchanged and textbox_editvaluechanged, both didn't work. yes i'm new in C#, but i think this is so simple. is this a problem in threading
string uppercase = this.txtLicense.Text.ToUpper();
this.txtLicense.Text = uppercase;i'm not sure i need to create a new thread just to force a textbox uppercase. :doh:
Probably a bit late now, but the normal way to do this is to intercept the character before it makes it into textbox rather than trying to alter it once its there. To do this, you want to intercept the WM_CHAR message (either by hooking the event KeyPress at form level of overriding a virtual OnKeyPress(Or similiar?) in a class deriving from TextBox. Then check the character and if its in the range a-z alter it to be A-Z (By subtracting 32 simplest way if ASCII). edit: That is of course assuming this is Winforms, an assumption I may have jumped on too soon as Bob mentions above.
Regards, Rob Philpott.