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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal VaishyaRank #990 · 2K reputationPosted Sep 2, 2013, 8:27 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 2, 2013, 8:36 PM EDT
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 2, 2013, 8:37 PM EDT
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 = "";
}
}
}