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
Loading
ali tuncerPosted Apr 22, 2016, 6:01 AM
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());
}
Shakti Singh DulawatPosted Apr 22, 2016, 5:57 AM