首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

小弟我想在DATAGRIDVIEW中(CGVIEW)录入数量,单价后,金额自动生成,为什么这段代码没反映

2012-04-15 
我想在DATAGRIDVIEW中(CGVIEW)录入数量,单价后,金额自动生成,为什么这段代码没反映C# codeprivate void Up

我想在DATAGRIDVIEW中(CGVIEW)录入数量,单价后,金额自动生成,为什么这段代码没反映

C# code
        private void UpdateBalance()        {            int i;            int account;            int qty;            int price;            for (i = 1; i < (CGVIEW.Rows.Count - 1);i++)            {                qty = 0;                price = 0;                account = int.Parse(CGVIEW.Rows[i - 1].Cells["ACCOUNT"].Value.ToString());                if (CGVIEW.Rows[i].Cells["QTY"].Value != null)                {                    if (CGVIEW.Rows[i].Cells["QTY"].Value.ToString().Length != 0)                    {                        qty = int.Parse(CGVIEW.Rows[i].Cells["QTY"].Value.ToString());                    }                }                if (CGVIEW.Rows[i].Cells["PRICE"].Value != null)                {                    if (CGVIEW.Rows[i].Cells["PRICE"].Value.ToString().Length != 0)                    {                        price = int.Parse(CGVIEW.Rows[i].Cells["PRICE"].Value.ToString());                    }                }                CGVIEW.Rows[i].Cells["ACCOUNT"].Value =(qty*price).ToString();            }        }        private void CGVIEW_CellValueChanged(object sender, DataGridViewCellEventArgs e)        {            UpdateBalance();        }


[解决办法]
我上面的代码可以通过数量*单价计算金额,也可以通过数量和金额来计算单价。只是VB.net写的。不明白再说吧。

热点排行