Re: DatagridView Validation assistance needed

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You can probably avoid your loop problem by setting a flag and only do
the validation when you are not trying to explicitly move to the empty
cell.

bool inValidateMove = false;
void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
if (!inValidateMove && e.ColumnIndex != 0 &&
(dataGridView1[0, e.RowIndex].Value == null
|| dataGridView1[0,
e.RowIndex].Value.ToString().Length == 0))
{
MessageBox.Show("Must enter col 0");
e.Cancel = true;
inValidateMove = true;
dataGridView1.CurrentCell = dataGridView1[0,
e.RowIndex];
inValidateMove = false;
}
}

======================
Clay Burch
Syncfusion, Inc.

.



Relevant Pages

  • Re: PHP strings -- newbie
    ... end of the validation, you should check if the array is empty and do ... Another approach is just setting a flag whenever ...
    (alt.php)
  • Re: DatagridView Validation assistance needed
    ... I am using a flag like you mentioned and the validation is going very ... bool inValidateMove = false; ... Clay Burch ...
    (microsoft.public.dotnet.framework.windowsforms.controls)