내 Windows 양식에 bindingsource를 사용하고 있습니다. 사용자가 할부 금액에 따라 원금을 기입 할 때 월별 금액을 계산합니다.하지만 문제는 금액을 입력 할 때 텍스트 변경 이벤트가 두 번 두 번째 시간 principal
null을 만듭니다. 어떻게 계산 작업을 완벽하게 해결할 수 있습니까?Datagridview textchange 이벤트 2 번 실행
private void prol04DataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox tx = e.Control as TextBox;
DataGridViewTextBoxCell cell = prol04DataGridView.CurrentCell as DataGridViewTextBoxCell;
if (tx != null && cell.OwningColumn == prol04DataGridView.Columns[5])
{
tx.TextChanged -= new EventHandler(tx_TextChanged);
tx.TextChanged += new EventHandler(tx_TextChanged);
}
}
이 내 텍스트 변경 이벤트입니다
void tx_TextChanged(object sender, EventArgs e)
{
try
{
TextBox Principal = (TextBox)sender;
Prol04 _ded = (Prol04)prol04BindingSource.Current;
/* Here P is PrinciplAmount*/
P = Convert.ToDecimal(Principal.Text);
Installment = Convert.ToDecimal(prol04DataGridView.CurrentRow.Cells[6].Value);
mnthPay = P/Installment;
_ded.MonthlyAmount = mnthPay;
_ded.Instalments =Convert.ToInt32(Installment);
prol04DataGridView.Refresh();
}
catch (Exception ex)
{
throw (ex);
}
}
![Datagrid Where i perform event][1]
컨트롤의 모든 텍스트 변경시 트리거됩니다. – V4Vendetta
첫 번째 함수에는 없습니다. 교착 상태 셀에서 작동하는 위치를 제어합니다. – Abhishek
@Abhishek 이벤트를 한 번만 호출하고 두 번 호출하지 않았습니다. ... – vikas