添加文本框默认时间和数据网格时间 [英] Add textbox default time and datagrid time
问题描述
嗨..
我想在文本框值和数据网格时间之间计算
文本框时间= 17分钟
datagrid列 - 开始时间,结束时间
默认时间= 17分钟
凝视时间= 7.59
完成时间=默认时间+开始时间
17 + 7.59 = 8:16
我尝试过:
txtCuringTime.Text =17;
private void DgASideView_CellValidated(object sender, DataGridViewCellEventArgs e)
{
if(DgASideView.CurrentCell.ColumnIndex == 1)
{
DgASideView。行[DgASideView.CurrentCell.RowIndex] .Cells [1] .Value =
cfun.convertdecimal(DgASideView.Rows [DgASideView.CurrentCell.RowIndex] .Cells [0] .Value.ToString()) + cfun.convertdecimal(txtCuringTime.Text.ToString());
}
}
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());
}
}
推荐答案
不要使用十进制类型,u 日期时间结构(系统)| Microsoft Docs [ ^ ]。然后,您可以将两个DateTime对象之间的差异视为 TimeSpan Struct (系统)| Microsoft Docs [ ^ ]。
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[^] .
这篇关于添加文本框默认时间和数据网格时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!