سلام سؤال خوبی بود من قبل به ذهنم رسیده بود و براش راه حل زیر رو نوشتم
که هیچ جا پیدا نمیشه اولش سه تا Textbox روی فرم قرار بده برای روز ماه و سال و حالا کد های زیر رو بنویس
(private void textBox1_KeyPress(object sender, KeyPressEventArgs e
}
if (textBox1.Text.Length == 0)
{
if (e.KeyChar >'3')
e.Handled = true ;
}
if (textBox1.Text.Length == 1)
{
if (textBox1.Text == "3")
{
if (e.KeyChar > '1')
e.Handled = true;
}
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (textBox2.Text.Length == 0)
{
if (e.KeyChar > '1')
e.Handled = true;
}
if (textBox2.Text.Length == 1)
{
if (textBox2.Text == "1")
{
if (e.KeyChar > '2')
e.Handled = true;
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length == 2)
textBox2.Focus();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox2.Text.Length == 2)
textBox3.Focus();
}
String date = textBox3.Text + "/" + textBox2.Text + "/" + textBox1.Text;
توسط
taghi69
(98 امتیاز)
●1