Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
|
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2010, 12:15 PM
Authorized User
 
Join Date: Apr 2006
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default TextBox/KeyDown/Enter Key

Greetings,

What is the appropriate way to code a Windows (not WPF) application in C# 3.0 that, when run, accept input to a TextBox after the user hits Enter?

I have a sample program that contains a TextBox and a Button. It uses a KeyDown event for the TextBox and checks that Enter has been pressed. The button's click event sets the TextBox's ReadOnly attribute to false. When I run the program I cannot type anything into the TextBox although the cursor is blinking in the TextBox. Once I click the button I can type into the TextBox and the KeyDown event fires when I hit enter.

The above behavior is not intuitive. One would assume that when the cursor is in a text box that one could enter data. How do I fix the program so I can enter data into the TextBox as soon as the program is run?

Thanks, in advance.
__________________
Sam Stamport
 
Old March 5th, 2010, 12:20 PM
Authorized User
 
Join Date: Apr 2006
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Problem solved

Never mind.

I found the solution. I added ReadOnly = false to the form's load event.
__________________
Sam Stamport





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter Key Event (Enter Key Only) Coby Excel VBA 0 February 6th, 2008 09:55 PM
capture return key in keydown event kawak_zx7 .NET Framework 1.x 1 April 23rd, 2007 11:21 AM
enter key on textbox, performs button event code?? squeakstar Visual Basic 2005 Basics 4 June 22nd, 2006 05:13 AM
Enter Key rwalker VB How-To 5 April 7th, 2004 11:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.