Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can we display age of someone's years months days separetely in textboxes when user clicks their dob in datetime picker

please show me the way 2 do this
Posted
Comments
Sergey Alexandrovich Kryukov 20-Mar-14 10:35am    
We are not doing your homework.
—SA

1 solution

Hi,
you can use Mouse down evend and Valuechanged event of date time picker check the below code.

C#
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
      {
          textBox1.Text = dateTimePicker1.Value.ToString("yyyy");
          textBox2.Text = dateTimePicker1.Value.ToString("MM");
          textBox3.Text = dateTimePicker1.Value.ToString("dd");
      }

      private void dateTimePicker1_MouseUp(object sender, MouseEventArgs e)
      {
          textBox1.Text = dateTimePicker1.Value.ToString("yyyy");
          textBox2.Text = dateTimePicker1.Value.ToString("MM");
          textBox3.Text = dateTimePicker1.Value.ToString("dd");
      }
 
Share this answer
 
Comments
BillWoodruff 20-Mar-14 7:52am    
I think this is a good answer, but why would you want to handle the 'MouseUp Event ?
syed shanu 20-Mar-14 20:39pm    
Just check with both events of datetime picker.value changed will be trigerd only when some value change on it thats fine.but also i make it in mouse up for even when you change year month or any other things in datetimepickter the event will trigger and value will change.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900