Date time picker vs label
  • In my form contain 3 label they are lab1, lab2 and lab3 respectively and one datetimepicker if i change the date time picker's year value all the lab3.text value should be current year lab2.text value should be previous year and via 
    example if i change the date time picker year value is 2014 means lab3.text=2014 la2.text=2013 and lab1.text=2012
    plz help me hw can i do it


  • 2 Comments sorted by
  • Vote Up0Vote Down WaqasWaqas
    172.00 Karma Accepted Answer
    you can use datetimepicker ValueChanged Event or any other as per your requirement and you can use below code.

     private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
            {
                label3.Text = dateTimePicker1.Value.Year.ToString();
                label2.Text=(dateTimePicker1.Value.Year-1).ToString();
                label1.Text = (dateTimePicker1.Value.Year - 2).ToString();
            }

  • thank u waqas its working

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Top Posters Weekly

Optimum Creative