S
Sudip_inn
Guest
see the code
private void dgList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgList.CurrentCell.ColumnIndex == 4)
{
if (dgList.CurrentRow.Cells[4].Value != DBNull.Value)
{
//string indentValue = dgList.CurrentRow.Cells[4].Value.ToString();
string indentValue = dgList.Rows[e.RowIndex].Cells[4].Value.ToString();
if (indentValue != "")
{
if (IsNumeric(indentValue))
{
//if (Convert.ToInt32(indentValue) < 2)
//{
// MessageBox.Show("Minimum Indent Value must be 2");
// dgList.CurrentRow.Cells[4].Value = "2";
//}
if (Convert.ToInt32(indentValue) > 10)
{
MessageBox.Show("Maximum Indent Value must be 10");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
else
{
MessageBox.Show("Indent Value must be numeric");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
else
{
MessageBox.Show("Indent Value can not be empty");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
}
}
}
public bool IsNumeric(string value)
{
return value.All(char.IsNumber);
}
I search google lot but no way i could not suppress the error. Cell 4 is textbox type column. when cell 4 has numeric value then no issue then moment i change any numeric value to alphabet then a error message comes like input string not in correct format
no way i can not handle this situation. i set the break point in the begining of the event but controls not going to stuck there.
how to resolve this issue. i even comment all the lines inside of the above event but still getting this error when insert alphabet in cell 4. this behavior not clear. why it is happening. please help.
Continue reading...
private void dgList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgList.CurrentCell.ColumnIndex == 4)
{
if (dgList.CurrentRow.Cells[4].Value != DBNull.Value)
{
//string indentValue = dgList.CurrentRow.Cells[4].Value.ToString();
string indentValue = dgList.Rows[e.RowIndex].Cells[4].Value.ToString();
if (indentValue != "")
{
if (IsNumeric(indentValue))
{
//if (Convert.ToInt32(indentValue) < 2)
//{
// MessageBox.Show("Minimum Indent Value must be 2");
// dgList.CurrentRow.Cells[4].Value = "2";
//}
if (Convert.ToInt32(indentValue) > 10)
{
MessageBox.Show("Maximum Indent Value must be 10");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
else
{
MessageBox.Show("Indent Value must be numeric");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
else
{
MessageBox.Show("Indent Value can not be empty");
dgList.CurrentRow.Cells[4].Value = "0";
}
}
}
}
}
public bool IsNumeric(string value)
{
return value.All(char.IsNumber);
}
I search google lot but no way i could not suppress the error. Cell 4 is textbox type column. when cell 4 has numeric value then no issue then moment i change any numeric value to alphabet then a error message comes like input string not in correct format
no way i can not handle this situation. i set the break point in the begining of the event but controls not going to stuck there.
how to resolve this issue. i even comment all the lines inside of the above event but still getting this error when insert alphabet in cell 4. this behavior not clear. why it is happening. please help.
Continue reading...