Click here to Skip to main content
11,706,159 members (53,075 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
I was writing a small program in Visual C# 2010 to ultimately be loaded on a handheld scanner with WinCE 5. Works great in 2010.

Come to find out, I needed to use the 2005 version. So I copied my code over to 2005, and now the TextChanged event doesn't trigger. I have tried it in a regular Windows App in 2005 as well, with the same results. The data goes into the textbox just fine, but changing the text doesn't trigger the event.

I have a textBox with this code attached. I test it in Windows by just Ctrl-V the data into it and it would trigger fine. In 2010, works great, not in 2005. On the handheld, the scanner will put info in this box.

private void textBox1_TextChanged(object sender, EventArgs e)
            //only get scan if txtbox isnt empty
            if (textBox1.Text.Length > 0)
                scanCode = ReadCode();
                //if scanCode == null that means it was a bad scan
                if (scanCode == null)
                    button1.Text = "Wrong Barcode - Try Again";
                    button1.BackColor = System.Drawing.Color.Red;
                    //Log that someone scanned the wrong barcode
                    log.WriteLine("Invalid Barcode scanned");
                    log.WriteLine("Code = " + scanCode);
                else //else it was a good scan

Anyone know of any differences between the versions that would keep this from triggering? Any help is greatly appreciated.
Posted 28-Oct-11 10:44am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


try to chceck whether textbox1 has property AutoPostBack=true and whether AutoEventWireUp in Page directive is true. If it is not true, you must bind method on event manualy.[^][^]

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Most likely reason is that the event is not hooked up. Search your project for "textBox1_TextChanged". You should find 2 instances, the definition and the event hookup in the auto-generated designer file.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

If you double click the button in VS2005 in the design view, you would most likely generate the actual event handler for the button in VS2005 app which will look like textbox1_TextChanged_1 . Coz when you pasted it from VS2010, it was created and hooked up with the button1 in VS2010 app, so to re-wire it to VS 2005 try re-generating the event handler and then paste the body over from VS2010.

Hope this helps.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 196
1 Sergey Alexandrovich Kryukov 151
2 ppolymorphe 61
3 Inimicos 60
4 ProgramFOX 50
0 OriginalGriff 9,050
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,636

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 28 Oct 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100