Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Fail Uppercase?

Fail Uppercase?

Scheduled Pinned Locked Moved C#
csharphelpquestion
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Midnight Ahri

    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:

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    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

    1 Reply Last reply
    0
    • M Midnight Ahri

      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:

      A Offline
      A Offline
      AmitGajjar
      wrote on last edited by
      #3

      You need to use LostFocus event to do the same.

      Thanks -Amit Gajjar (MinterProject)

      M 1 Reply Last reply
      0
      • A AmitGajjar

        You need to use LostFocus event to do the same.

        Thanks -Amit Gajjar (MinterProject)

        M Offline
        M Offline
        Midnight Ahri
        wrote on last edited by
        #4

        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.

        1 Reply Last reply
        0
        • M Midnight Ahri

          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:

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          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[^]

          B 1 Reply Last reply
          0
          • L Lost User

            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[^]

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #6

            After the second bounce the value will not change so the event shouldn't fire forever.

            L 1 Reply Last reply
            0
            • M Midnight Ahri

              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:

              B Offline
              B Offline
              BobJanova
              wrote on last edited by
              #7

              Is this a desktop or web app?

              1 Reply Last reply
              0
              • B BobJanova

                After the second bounce the value will not change so the event shouldn't fire forever.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                Does the setter of the text-property of the textbox include a check to see whether the value is the same, or not?

                Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                B 1 Reply Last reply
                0
                • L Lost User

                  Does the setter of the text-property of the textbox include a check to see whether the value is the same, or not?

                  Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #9

                  It should, at least for the TextChanged event (the clue's in the name!), but I haven't actually tested it right now.

                  L 1 Reply Last reply
                  0
                  • B BobJanova

                    It should, at least for the TextChanged event (the clue's in the name!), but I haven't actually tested it right now.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    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[^]

                    1 Reply Last reply
                    0
                    • M Midnight Ahri

                      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:

                      R Offline
                      R Offline
                      Rob Philpott
                      wrote on last edited by
                      #11

                      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.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups