Adding validation to text box.

Posted by Achiever_Aman under ASP.NET on 7/28/2013 | Points: 10 | Views : 825 | Status : [Member] | Replies : 4
How to add validation in textbox in window's form.
Adding validation control in web form is quite easy as it is available in toolbox but in windows form, toolbox doesnot show validation control. PLease help..

Achiever_aman


Responses

Posted by: Satyapriyanayak on: 7/28/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Which type of validation you want?


Blank validation on textbox in windows apps

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 Validation_on_textbox
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
foreach (Control c1 in this.Controls)
{
if (c1 is TextBox)
{
if (c1.Text == "")
{
MessageBox.Show("Name Field cannnot be blank");
c1.BackColor = Color.Orange;
textBox1.Focus();
}
else
{
MessageBox.Show("Correct");
c1.BackColor = Color.White;
}
}
}
clear();
}
private void clear()
{
textBox1.Text = "";
}
}
}



If this post helps you mark it as answer
Thanks

Achiever_Aman, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/28/2013 [Member] Starter | Points: 25

Up
0
Down
Hi
refer this link it might be usefull to you
http://www.codeproject.com/Articles/13922/Validate-user-input-in-Windows-Forms

http://www.dotnetfunda.com/forums/thread12068-how-to-validate-textbox-in-windows-application.aspx

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Achiever_Aman, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 7/29/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi Aman Agarwal,
You can check the logic here
http://www.dotnetfunda.com/forums/thread15754-donot-allow-any-space-in-textbox.aspx
Approch is:
You have to write your own logic to validate TextBox

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Achiever_Aman, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/29/2013 [Member] Starter | Points: 25

Up
0
Down
What type of validation you need to do, In Windows form there is no validation controls, you need to write your own validations
let us know what validation you need, we will support

Regards,
Jayakumar Selvakani

Achiever_Aman, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response