C# 更改datagridview单元格值时更新标签文本
Allocated hrs label是为每个部门分配的总小时数,left hours是在单元格结束编辑时减去分配的小时数后剩下的小时数 在Datagridview中,一旦我从下拉列表中选择部门值并输入tmh单元格值,然后在cellend编辑行上,我必须更新左侧的hrs标签文本,但我无法获得这种情况的逻辑 这是我的密码C# 更改datagridview单元格值时更新标签文本,c#,mysql,datagridview,C#,Mysql,Datagridview,Allocated hrs label是为每个部门分配的总小时数,left hours是在单元格结束编辑时减去分配的小时数后剩下的小时数 在Datagridview中,一旦我从下拉列表中选择部门值并输入tmh单元格值,然后在cellend编辑行上,我必须更新左侧的hrs标签文本,但我无法获得这种情况的逻辑 这是我的密码 #region THM CALCULATION. int column = ProjectActivitiesGrid.CurrentCell
#region THM CALCULATION.
int column = ProjectActivitiesGrid.CurrentCell.ColumnIndex;
string headerText = ProjectActivitiesGrid.Columns[column].HeaderText;
DataGridViewRow d = this.ProjectActivitiesGrid.Rows[e.RowIndex];
String department = d.Cells[0].Value.ToString();
if (department != null)
{
String chk = m_Project.projdepthrs.Where(c => c.DEPARTMENT == department).Select(c => c.DEPARTMENT).FirstOrDefault();
if (chk == null)
{
MessageBox.Show("Please fill up department alloted hrs first");
d.Cells[1].ReadOnly = true;
d.Cells[2].ReadOnly = true;
d.Cells[3].ReadOnly = true;
d.Cells[4].ReadOnly = true;
d.Cells[5].ReadOnly = true;
d.Cells[6].ReadOnly = true;
d.Cells[7].ReadOnly = true;
}
else
{
d.Cells[1].ReadOnly = false;
d.Cells[2].ReadOnly = false;
d.Cells[3].ReadOnly = false;
d.Cells[4].ReadOnly = false;
d.Cells[5].ReadOnly = false;
d.Cells[6].ReadOnly = false;
d.Cells[7].ReadOnly = false;
String tmh = m_Project.projdepthrs.Where(c => c.DEPARTMENT == department).Select(c => c.TMH).First();
LBLAllotedhrs.Text = tmh;
LBLLefthrs.Text = tmh;
}
if (d.Cells[5].Value != null)
{
foreach (DataGridViewRow rw in ProjectActivitiesGrid.Rows)
{
LBLLefthrs.Text = (Convert.ToInt32(LBLLefthrs.Text) - Convert.ToInt32(d.Cells[5].Value)).ToString();
}
}
else
{
LBLLefthrs.Text = "";
}
}
else
MessageBox.Show("please select department");
#endregion
这是一个复制品