Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to get working hours of day
i m using one datetimepicker for taking entry time and one datetimepicker for taking exit time.
using these times i calculate total hours by formula Exit time-Entry time
i want to display these working hours in textbox as soon as user enters exit time

i used Enter event on textbox which calculates and displays working hours when i click in textbox

Is there any way by which as soon as enter time in timepickers, the working hours will automatically appear in textbox without any need to click anywhare on form?
which event i can use for this?
Posted

As you want to trigger recalculation on change in time, handle the event DateTimePicker.ValueChanged.

—SA
 
Share this answer
 
Hi,
Try This
C#
private void DateTimePicker1_ValueChanged(System.Object sender, System.EventArgs e)
{
	//Do Your CalCulation Hear and Set the value to TextBox
}
 
Share this answer
 
v2
Comments
Member 8081020 3-Aug-11 3:55am    
It worked thanks
RaviRanjanKr 3-Aug-11 15:06pm    
Nice answer, My 5+
Why not use the Leave[^] event of your DateTimePicker[^] controls? Out of curiosity, is this your personal application? Because if its not, its not a wise move to use datetimepicker as people may cheat their login/logout. :)
 
Share this answer
 
Comments
Member 8081020 3-Aug-11 2:02am    
Yes It's my personal application.
But my aim is to build this software for Industrial use.
but since i m fresher and dont know much so doing just simple thing initially
Thanks for solution
Member 8081020 3-Aug-11 2:30am    
sorry but it's not working

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