public frmDepositEdit()
{
InitializeComponent();
dgvCardType.AutoGenerateColumns = false;
dgvCardType.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgvCardType_EditingControlShowing);
}
void dgvCardType_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress);
}
//求实收金额。
decimal addMoney = 0;
void Control_KeyPress(object sender, KeyPressEventArgs e)
{
//要处理的事件信息。
decimal intNumberBoxes = 0;
decimal someAmount = 0;
if (char.IsNumber(e.KeyChar))
{
int column = dgvCardType.CurrentCellAddress.X;
int row = dgvCardType.CurrentCellAddress.Y;
if (column == 2)
{
string cellValue = Char.ToString(e.KeyChar);
string test = dgvCardType[column, row].EditedFormattedValue.ToString();
test = test + cellValue;
intNumberBoxes = Convert.ToDecimal(test);
if (intNumberBoxes > 999)
{
e.Handled = true;
}
someAmount = decimal.Parse(dgvCardType.Rows[dgvCardType.CurrentCellAddress.Y].Cells[1].Value.ToString());
txt_现金金额.Text = (addMoney + intNumberBoxes * someAmount).ToString();
}
}
}
06
2012
07
asp.net中DataGridView控件中,某个列的单元格输入值改变时触发命令的方法
发布:郑德才博客 | 分类:知道理解 | 评论:2 | 浏览:
相关文章:
DataGridView隔行变色鼠标经过改变形状及行变色 (2012-8-15 20:54:55)
C#——DataGridView分页功能的实现 (2012-6-15 0:28:25)
C# 绑定DataGridView下某个文件夹下的txt文本文件 (2012-5-17 20:57:45)
C# DataGridView批量修改、删除数据 (2012-4-13 21:7:31)
DataGridView如何调整列宽 (2012-4-2 13:22:41)
Datagridview操作之Datagridview删除选择性多行 (2012-3-29 16:29:31)
Datagridview操作之Datagridview分页 (2012-3-28 9:40:36)
datagridview操作之数据全选和反选 (2012-3-28 9:38:44)
Datagridview绑定数据时行变色,数据行自动编号 (2012-3-28 9:36:46)
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
评论列表: