dotnetspider.com


 


TutorialsForumResourcesReviewsJobsInterviewVideosCommunitiesProjectsTraining

Subscribe to Subscribers


Online MembersSankar
Sunitha
Ashokkumar
Anu George
chanti
Falguni
Prachi Kulkarni
cloud
Prasad kulkarni
Gokula
Prabu Thangavelu
More...




Resources » Code Snippets » C# Syntax


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


Posted Date:     Category: C# Syntax    Rating: 1 out of 5
Author: Member Level: Gold    Points: 8 (Rs 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;
}
}
}


Did you like this resource? Share it with your friends and show your love!





Responses to "Textbox validation - Allows Only Alpha-Numeric’s (C# Win Forms)"
Author: Miss Meetu Choudhary    10 Apr 2009Member Level: Gold   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      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Textbox validation - Allows Only Letters
    Previous Resource: Simple code to make data table
    Return to Resources
    Post New Resource
    Category: C# Syntax


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Textbox Validation  .  

    My Profile

    Active Members
    TodayLast 7 Daysmore...


    Awards & Gifts


    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds



    About Us    Trademark Disclaimer    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.