Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 30th, 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 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?
Reply With Quote
  #2 (permalink)  
Old September 30th, 2003, 11:05 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,957
Thanks: 79
Thanked 1,556 Times in 1,533 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.
Reply With Quote
  #3 (permalink)  
Old October 2nd, 2003, 11: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
Reply With Quote
  #4 (permalink)  
Old August 18th, 2006, 11: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

Reply With Quote
  #5 (permalink)  
Old August 20th, 2006, 03: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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simulating a key press with c++ Bourne C++ Programming 2 April 13th, 2007 03:03 PM
How to catch TAB key press with JScript? woojtii Javascript How-To 0 March 28th, 2007 06: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



All times are GMT -4. The time now is 07:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.