Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..
I want to calculate between textbox value and datagrid time

textbox time = 17 minutes
datagrid columns -starting time,finishing time

default time =17 minues
staring time=7.59
finishing time = default time + starting time
17 + 7.59 =8:16

What I have tried:

txtCuringTime.Text="17";

private void DgASideView_CellValidated(object sender, DataGridViewCellEventArgs e)
{
if (DgASideView.CurrentCell.ColumnIndex == 1)
{
DgASideView.Rows[DgASideView.CurrentCell.RowIndex].Cells[1].Value =
cfun.convertdecimal(DgASideView.Rows[DgASideView.CurrentCell.RowIndex].Cells[0].Value.ToString()) + cfun.convertdecimal(txtCuringTime.Text.ToString());

}
}
Posted
Updated 2-Dec-18 22:46pm

1 solution

Do not use Decimal type for times, use the DateTime Struct (System) | Microsoft Docs[^] . You can then get the difference between two DateTime objects as a TimeSpan Struct (System) | Microsoft Docs[^] .
 
Share this answer
 

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