hi..
i want to make a application in windows forms.
I wish, i want to validate the user. like enter name, city, dob and etc. are fill is compusly.
How to do this ??
please explain.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Sep 3, 2013, 12:37 AM
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 = "";
}
}
}
Sanjeeb LenkaPosted Sep 3, 2013, 12:36 AM
you can refer to this some examples are there.
http://www.codeproject.com/Articles/13922/Validate-user-input-in-Windows-Forms
http://www.dotnetfunda.com/codes/code109-textbox-validation-in-windows-application-using-csharp.aspx
Kunal VaishyaPosted Sep 3, 2013, 12:27 AM