dev gridview之外的某个文本框的值变动时触发表格中的几列跟着变动
作者:互联网
private void txtJgRate_TextChanged(object sender, EventArgs e)
{
decimal jgRate = Convert.ToDecimal( this.txtJgRate.Text.Trim());
try
{
for (int i = 0; i < this.gridView1.RowCount; i++)
{
//循环遍历整个gridview明细行
//string batchcode = this.gridView1.GetRowCellValue(i, gridView1.Columns[@"订单批次号"]).ToString();
//DateTime senddate = Convert.ToDateTime(this.gridView1.GetRowCellValue(i, gridView1.Columns[@"发货日期"]));
decimal qtys = Convert.ToDecimal(this.gridView1.GetRowCellValue(i, gridView1.Columns[@"Qtys"]));
decimal dj = Convert.ToDecimal(this.gridView1.GetRowCellValue(i, gridView1.Columns[@"dj"]));
decimal jgdj = dj * jgRate;
decimal jgje = qtys * jgdj;
this.gridView1.SetRowCellValue(i, gridView1.Columns["jgdj"], jgdj.ToString("f4"));
this.gridView1.SetRowCellValue(i, gridView1.Columns["jgje"], jgje.ToString("f2"));
}
}
catch
{
MessageBox.Show(@"err:数据转化错误!");
}
}
标签:变动,gridview,decimal,Convert,文本框,GetRowCellValue,jgdj,gridView1,Columns 来源: https://blog.csdn.net/he198108/article/details/114835231