Public Form1(){InitializeComponent();}
Private void Form1_Load(object sender, EventArgs e)
{
TextBox Txt_1=new TextBox();
TextBox Txt_2=new TextBox();
Button btn=new Button();
Txt_1.Name=”txt_Name”;
Txt_2.Name=”txt_ID”;
btn.Name=”btn_submit”;
Txt_1.Location=new Point(40,50);
Txt_2.Location=new Point(40,100);
btn.Location=new Point(40,150);
Txt_1.Text=”Name”;
Txt_2.Text=”ID”;
btn.Text=”Submit”;
Txt_1.V***ble=true;
Txt_2.V***ble=true;
btn.V***ble=true;
btn_submit.Clicl+=new EventHandler(btn_Submit_Click);
This.Controls.Add(Txt_1);
This.Controls.Add(Txt_2);
This.Controls.Add(btn);
}
private void btn_Submit_Click(object sender,System.EventArgs e)
{
Int err=0;
If(ChechName()===false)
{
err=1;
txt_Name.Text=””;
}
If(ChechID()===false)
{
err=1;
txt_ID.Text=””;
}
If(err==1)
{
Return ;
}
txt_Name.V***ble=false;
txt_ID.V***ble=false;
btn_submit.V***ble=false;
Label lbl_text1=new Label();
Label lbl_text2=new Label();
lbl_text1.Location=New Point(40,50);
lbl_text2.Location=New Point(40,100);
lbl_text1.Text=”Name : ”+txt_Name.Text;
lbl_text2.Text=”ID : ”+txt_ID.Text;
lbl_text1.V***ble=true;
lbl_text2.V***ble=true;
This.Controls.Add(lbl_text1);
This.Controls.Add(lbl_text2);
}
private Bool ChechName()
{
Regex reg=new Regex(@"^[a-zA-z]+$");
Match match=reg.Match(txt_Name.Text);
if(match.Success)
{
return true;
}
else
{
return false;
}
}
private Bool CheckID()
{
Regex reg=new Regex(@"^[1-9]{4,9}$");
Match match=reg.Match(txt_ID.Text);
if(match.Success)
{
return true;
}
else
{
return false;
}
}