connectseekers.com

Tuesday, 10 February 2015

Limit OR Restrict Number of Characters in Textbox C#.Net In windows Application

2/10/2015 - By Pranav Singh 0

In this article I will show you how you can limit or restrict number of characters in textbox c#.net in windows application.


So for this article first we will create a new windows application create the below form.


Now add the below code into the form.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length <= 10)
            {
                label1.Text = "Total No of Characters : " + textBox1.Text.Length;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.MaxLength = 10;
        }

    }
}

On page load I have assign the max length of the textbox. And on textbox change I have calculated the total no of character added in the textbox.

Now we have run the application and check the output.


DOWNLOAD

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top