在gridview中使用Keypress事件 [英] Using Keypress event in gridview

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

问题描述

我在更新面板中有网格,它有金额列..在"n"行中,我希望在按键上显示所有金额列的总计,并在txtTotalAmt中显示它,对于金额列中的每次插入,都必须添加总计在txtTotalAmt

i have grid in update panel it has amount column.. in that ''n'' rows i want total of all amount column on keypress and display it in txtTotalAmt,for each insertion of amount in amount column it has to add total in txtTotalAmt

推荐答案

中,您可以将Java脚本用于按键事件.
或者您可以使用gridview的文本框文本更改事件.

为此,您需要在行绑定事件中绑定事件处理程序
you can use java script for key press event..

or u can use textbox text changed event of gridview.

for that u need to bind event handler in row bound event


Hi Kiirrii

尝试以下代码:-
Hi Kiirrii

Try this code:-
private void DataGridView1_KeyPress(object sender, KeyPressEventArgs e)
     {
       foreach(DataGridViewRow row in DataGridView1.Rows)
        {
          txtTotalAmt.Text = Convert.ToString(Convert.ToDouble(txtTotAmount.Text)+
                             Convert.ToDouble(row.Cells["amount"].value))
        }
     }



希望这项工作!!



Hope this work !!


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

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