C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Textbox validation - Allows Only Alpha-Numeric’s (C# Win Forms)


Posted Date: 12 Dec 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: KRMember Level: Gold    
Rating: 1 out of 5Points: 8



The following steps allows the user to enter only Alpha-Numeric’s (0 to 9/a to z/ A to Z),
-> Drag and drop textbox from toolbox to form
-> Register Textbox KeyPressEvent

Code:
--------

Using System;
using System.Windows.Forms;
using System.Text;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

// Textbox KeyPress event block
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
// Allows only Alpha-Numeric’s
if (!(Char.IsLetter(e.KeyChar) || Char.IsDigit(e.KeyChar) || Char.IsControl (e.KeyChar)))
e.Handled = true;
}
}
}



Responses

Author: Miss Meetu Choudhary    10 Apr 2009Member Level: Diamond   Points : 1
For description

Please Describe your code as well to make it more efficient we respect your contributions.

And it will be of great help to viewers if they are well described.


Thanks and Regards
Meetu Choudhary
Editor


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Textbox Validation  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Textbox validation - Allows Only Letters
Previous Resource: Simple code to make data table
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use