Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys I have button click event (witch is working on timer) and i have DatetimePicker and can you help me how i can bound date and time when button was clicked on datetime picker
C#
private void timer1_Tick(object sender, EventArgs e)
       {   button1_Click(sender, e);
           button2_Click_1(sender, e);

           second = second + 1;

       }

this is my datetime picker format

What I have tried:

public Form1()
{
InitializeComponent();
dateTimePicker1.Format = DateTimePickerFormat.Long;

dateTimePicker1.ShowUpDown = false;
}
//here is datetime picker
i tried here to Get the Button event but i can't erroring me beaocuse he don't see this event
Posted

1 solution

The timer is not for getting the current time. It is for triggering actions at a given time (or at given intervals again and again). If I read your question correctly, you don't need the timer.

If you want to set the DateTimePicker to the time the button was pressed, set its Value property:
C#
void button1_Click(object sender, EventArgs e)
{
    dateTimePicker1.Value = DateTime.Now;
}
 
Share this answer
 
Comments
GTR0123 16-Feb-16 4:31am    
a ok i get it thnx

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