我们如何使用datagridview的cellleave事件? [英] how can we use cellleave event of datagridview ?

查看:397
本文介绍了我们如何使用datagridview的cellleave事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将两个单元格值相乘.离开第二个单元格后,答案应显示在第三个单元格中...

i want to multiply two cell value.and after leaving second cell the answer should be display in third cell...

推荐答案

使用此代码

Use this code

private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
 {
   if (e.ColumnIndex == 1) //if second cell
    {
       dataGridView1.Rows[e.RowIndex].Cells[2].Value =   Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[0].Value) * Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[1].Value);
 }
}


这篇关于我们如何使用datagridview的cellleave事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆