当用户单击单元格时,当它具有焦点时,如果我想打开另一个文件,我会收到一条Argument Out Of Range Exception Error
我添加的错误消息try catch & data Error event handler
,但我仍然收到此错误。我怎样才能解决这个问题??
private void datagridview_CellValidating(object sender, CellValidatingEventArgs e)
{
try
{
if (e.ColumnIndex == 2 || e.ColumnIndex == 3)
{
datagridview.Rows[e.RowIndex].ErrorText = "";
int newInteger;
if (datagridview.Rows[e.RowIndex].IsModified)
return;
if (!int.TryParse(e.Value.ToString(),
out newInteger) || newInteger < -50000 || newInteger > 50000)
{
e.Cancel = true;
string errorMesssage = d_LanguageDropDownList.SelectedItem.ToString() == "French" ? "Entrez des valeurs décimales entre -50000 et 50000"
: "Enter decimal values between -50000 to 50000";
datagridview.Rows[e.RowIndex].ErrorText = errorMesssage;
}
}
}
catch (Exception exception)
{
}
}
private void datagridview_DataError(object sender, GridViewDataErrorEventArgs e)
{
}