示例#1
0
        private void dgvJobs_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            RFMDataGridView grd = (RFMDataGridView)sender;

            if (grd.DataSource == null || grd.Rows.Count == 0)
            {
                return;
            }

            // строка данных
            DataRow r = ((DataRowView)((DataGridViewRow)grd.Rows[e.RowIndex]).DataBoundItem).Row;

            DataGridViewColumn c           = grd.Columns[e.ColumnIndex];
            string             sColumnName = c.Name.ToUpper();

            if (sColumnName.Equals("dgvcUnitsQnt".ToUpper()) || sColumnName.Equals("dgvcPrice".ToUpper()))
            {
                decimal nUnitsQnt, nPrice;
                try
                {
                    nUnitsQnt = Decimal.Parse(r["UnitsQnt"].ToString());
                    nPrice    = Decimal.Parse(r["Price"].ToString());
                }
                catch
                {
                    nUnitsQnt = nPrice = 0;
                }
                r["TaskAmount"] = nUnitsQnt * nPrice;
                grd.Refresh();
            }
        }