Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 September 30th, 2003, 09:56 AM
Authorized User
 
Join Date: Jun 2003
Location: Rio de Janeiro, Rio de Janeiro, Brazil.
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default TAB KEY working together KEY PRESS event

I use the Keypress event to verify when the user typing the ENTER KEY, like below:

if (e.KeyChar == 13){//using the ASCII code of a ENTER KEY
    if (this.cboSiglacolecao.SelectedIndex > 0){

    this.siglaColecao = "";
        this.cboSiglacolecao.DroppedDown = false;
        {
}

But now i need to verify when the user typing the EMTER KEY and the TAB KEY.
The ASCII code of the TAB KEY is (11 - Vertical Tabulator and 9 - Horizontal Tabulator) but when i use them the code does not function, like below:

if (e.KeyChar == 13 || e.KeyChar == 9){//using the ASCII code of a ENTER KEY and TAB KEY
    if (this.cboSiglacolecao.SelectedIndex > 0){

    this.siglaColecao = "";
        this.cboSiglacolecao.DroppedDown = false;
        {
}

How can i execute the code when the user pressures the TAB KEY?
OR
How can i capture the ASCII code of the TAB KEY?
 
Old September 30th, 2003, 10:05 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Thomaz,

You can check for \t (tab) and \r (enter) instead of numeric values. This:
Code:
if (e.KeyChar == '\t' || e.KeyChar == '\r')
{
    MessageBox.Show("Tab or Enter pressed");
}
should do the trick.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 2nd, 2003, 10:56 AM
Authorized User
 
Join Date: Jun 2003
Location: Rio de Janeiro, Rio de Janeiro, Brazil.
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar;

Thanks for your reply...

your solution will solve my trouble..

Thomaz
 
Old August 18th, 2006, 10:04 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi, I´m having a big problem, well I´m porgraming with c#.net 2005, and I´d like to make a validation.
I have 2 textbox, in the first one I only want numbers and ",".
In the second textbox I only want letters.
I was trying it with visual basic .net 2005 with ascii code. But now I want to do it with c#.net 2005.
thnks

 
Old August 20th, 2006, 02:47 PM
Authorized User
 
Join Date: Aug 2006
Location: , , Netherlands.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

jammer,
For windows application, check the Char structure in C#. For web application do some client side code.

Regards,
.NETamateur
Electrical Engineer




Similar Threads
Thread Thread Starter Forum Replies Last Post
Simulating a key press with c++ Bourne C++ Programming 2 April 13th, 2007 02:03 PM
How to catch TAB key press with JScript? woojtii Javascript How-To 0 March 28th, 2007 05:53 AM
key press event in webforms agnihotrived ADO.NET 4 March 19th, 2005 03:22 PM
Tab Key event ssrinivas VB How-To 5 November 4th, 2004 04:29 PM
Force a Key Press? ashley_y VB How-To 2 January 9th, 2004 03:59 PM





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