Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / December 2004

Tip: Looking for answers? Try searching our database.

KeyDown Event in a Text Box Control - trying to capture Keys???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GTDriver - 29 Dec 2004 03:15 GMT
I have two textbox controls on my form. One textbox is used for entering
text,numbers, other char's, etc. The other textbox control is used for
displaying the same info I type in the first textbox.

As I type each character, it should automatically add the same value to the
other textbox(concatenate all chars). However, as I type function keys,
shift, control,alt, etc, this is also transfer to the other text box. for
example, if I press the F1 key, 'F1' appears in the second textbox. If I
press shift+y, 'ShiftY' appears in the textbox.

How do I eliminate these special function keys and just display the text?
I'm trying to use Keys enumeration values but this seems like a tedious task
to code for all the combinations.

Second of all, when I press a letter and when I debug the keydown event, the
letter is in upper case, when I know that caps lock is not on. How do I make
sure if I type lowercase, it will appear lowercase or if I type uppercase, it
will appear uppercase?
Signature

Sincerely,

KA

Morten Wennevik - 29 Dec 2004 18:28 GMT
Hi GTDriver,

You could capture the KeyPress event and check if the KeyChar property of  
the KeyPressEventArgs is of type Char.IsLetterOrDigit(), if so, pass it on  
to the other TextBox, if not, ignore it.  However, you may need to take  
into account deletion of characters involving moving the cursor and  
deleting a selection.

> I have two textbox controls on my form. One textbox is used for entering
> text,numbers, other char's, etc. The other textbox control is used for
[quoted text clipped - 19 lines]
> uppercase, it
> will appear uppercase?

Signature

Happy Coding!
Morten Wennevik [C# MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.