Advertisement

02.09.2008 at 06:07AM PST, ID: 23150043
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

tabControl and textBox Keypress event:  textBox will not take input.

Tags: Microsoft, C#, 2005 Express
I'm working on a program that takes several inputs, does some calculations and then plots a graph.  The inputs are handled with a KeyPress event.  All of the textBoxes are in a groupBox control.  Everything was working fine until I decided to put the optional inputs on a separate tabControl with two tabPages.  In the process I did some cutting and pasting of the groupBox with the original textBoxes.  Cut some of the textBoxes out of the original groupBox and pasted them in a new groupBox on the new tabControl.  I also
created a new textBox and places it on the tabControl.

Now the original textBoxes will not accept any input and only beep when I press Return.  The only textBox that accepts input now is the new textBox on the tabControl that was created new (not cut and pasted).
I created a small program with a tabControl and  two textBoxes, one on the tabControl.  It worked fine, so I suspect that the cutting and pasting I did may have tangled something up.  I have tried debugging by stepping into the code, but it never gets to the Keypress event, I just get a beep.

Here's how the KeyPress events are handled:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            char c = e.KeyChar;
            int i = (int)c;
            if (i == 13) // The "Return/Enter" key was pressed
            {
                e.Handled = true;
                if (textBox1.Text != "")
                {
                    inputOD = System.Convert.ToDouble(textBox1.Text);
                    Calculate();
                    this.ActiveControl = textBox2;
                }
                else
                    MessageBox.Show("Nothing was entered!", "Entry Error");
            }
        }
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: rturney
Solution Provided By: FernandoSoto
Participating Experts: 1
Solution Grade: A
Views: 156
Translate:
Loading Advertisement...
02.09.2008 at 06:39AM PST, ID: 20857382

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.09.2008 at 06:52AM PST, ID: 20857430

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.09.2008 at 07:50AM PST, ID: 20857624

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.09.2008 at 07:53AM PST, ID: 20857635

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.09.2008 at 06:39AM PST, ID: 20857382

Rank: Guru

Place a breakpoint in the first line of the textBox1_KeyPress event handler. If it does not break there when you run the application and attempt to add text to the TextBox then terminate the application and go to the design view and click on the textBox1 control and go to the property page and click on the events button and make sure that there is a event defined for the KeyPress event and that they are spelled the same way. The IDE might of removed the name when you cut and past code around.
Accepted Solution
 
02.09.2008 at 06:52AM PST, ID: 20857430
Sure enough, following your instructions, the app did not break at the first line of the Keypress event.  Selecting the textBox and double-clicking on the Keypress event created a new stub with:
private void textBox1_KeyPress_1(object sender, KeyPressEventArgs e).  It has added a "1" to the control name.  

Does this mean I now have to recreate the Keypress events for all the textboxes?
 
02.09.2008 at 07:50AM PST, ID: 20857624
Thanks to your info I have discovered, unlike VB6, when using Visual Studio languages, in this case C#, that moving a control like a textBox from a groupBox to somewhere else does not require you to cut it and then paste it.  It appears then you can drag the textBox out of the groupBox with no problem, where in VB6 you had to cut the control out of the groupBox.  So it seems that the cutting removed the textBox control from the event handler and when I pasted it back it had a new name?  Strange because the Properties doesn't show any newly named textBoxes.  They all have retained their old names.  The only evidence is when you double click the Keypress event handler that you see a "_1" was added.

What's the best way to clean up the mess?
 
02.09.2008 at 07:53AM PST, ID: 20857635

Rank: Guru

If you go back to the property page for the control and select the KeyPress event by single clicking and then click on the down arrow in the ComboBox to the right you will find 2 or more event handlers that match the delegate of the TextBox. Select textBox1_KeyPress or textBox1_KeyPress_1 and delete the other in code. When you double clicked on the event you added another event method to the code seeming the default name was already in code it added the _1 to the end of the default name to create the new method.
 
 
02.09.2008 at 08:04AM PST, ID: 20857680
Not a problem, glad I was able to help.  ;=)
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628