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 Letters


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



C# Win Forms:
------------------
The following steps allows the user to enter only letters (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 letters
if (!(Char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar)))
e.Handled = true;
}
}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

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: Inserting image into database & retriving from database.
Previous Resource: Textbox validation - Allows Only Alpha-Numeric’s (C# Win Forms)
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