Hi....
I am using windows application (VB.NET). I have a form with datagridview with columns qty , unit price and cost . The Cost column is qty * unit price column. When i enter unit cost in unit price column i wrote this calculation in cell end edit event for datagridview but when mouse left the focus only the event do calculations.. Is there any other event to do calculation in data gridiview so that calculation is correct.
Thanks and Regards
Sankar
Alternative to Cell End Edit in Datagridview ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Shakti Singh DulawatRank #668 · 3.6K reputationPosted Apr 22, 2016, 1:57 AM EDT
ali tuncerRank #1,499 · 1.1K reputationPosted Apr 22, 2016, 2:01 AM EDT
I think you can use KeyPressEventHandler, it is probably the same in VB, but I don't know the syntax. Here is a C# code for your reference:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridViewTextBoxEditingControl tb = (DataGridViewTextBoxEditingControl)e.Control;
e.Control.KeyPress += new KeyPressEventHandler(dataGridViewTextBox_KeyPress);
}
private void dataGridViewTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show(e.KeyChar.ToString());
}