private void grdSleeves_Validating(object sender, CancelEventArgs e)
{
try
{
if (sender is RadGridView)
{
RadGridView grid = (RadGridView)sender;
if (grid.CurrentCell.ColumnIndex == (int)enum_grid_sleeve.picked)
{
int picked = Convert.ToInt32(grid.ActiveEditor.Value);
int available = Convert.ToInt32(grid.CurrentRow.Cells[(int)enum_grid_sleeve.paqavailable].Value);
int required = Convert.ToInt32(grid.CurrentRow.Cells[(int)enum_grid_sleeve.paq].Value);
if (available < picked) { e.Cancel = true; MessageBox.Show("Picking more than available."); }
else if (required < picked) {e.Cancel = true; MessageBox.Show("Picking more than required."); }
}
}
}
catch { }
}
5 Answers, 1 is accepted
I tested the code. It seems to be working with my test project. Maybe there is something in your application that affects the validation process. Could you please open a support ticket and send us the code for your application. We will investigate the issue in detail and find a proper solution.
I am looking forward to your reply.
Best wishes,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The problem is easy to duplicate, but I left out a detail. The form that is causing the loop is a MDI Child form. So if you add this to the mixture, you'll see the problem
Bill
Thank you for the additional info.
Now I reproduced the issue, although I am not yet sure whether this is a RadGridView issue. We will research the case and will consider addressing the issue in one of our upcoming releases.
You could use a flag property to workaround it. Take a look at the sample below:
bool validating = false; |
void radGridView1_Validating(object sender, CancelEventArgs e) |
{ |
try |
{ |
if (!validating) |
{ |
validating = true; |
if (sender is RadGridView) |
{ |
RadGridView grid = (RadGridView)sender; |
if (grid.IsInEditMode && grid.CurrentCell.ColumnIndex == 2) |
{ |
int picked = Convert.ToInt32(grid.ActiveEditor.Value); |
int available = Convert.ToInt32(grid.CurrentRow.Cells[2].Value); |
int required = Convert.ToInt32(grid.CurrentRow.Cells[2].Value); |
e.Cancel = true; |
MessageBox.Show("Picking more than available."); |
} |
} |
validating = false; |
} |
} |
catch { } |
} |
Should you have any questions, I will be glad to help.
Regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I haven't noticed this issue because I used numeric columns in my test. This issue is specific to the text column; thank you for reporting it. You can work around the issue by setting the old value explicitly. Please see the sample:
void radGridView1_Validating(object sender, CancelEventArgs e) |
{ |
try |
{ |
if (!validating) |
{ |
validating = true; |
if (sender is RadGridView) |
{ |
RadGridView grid = (RadGridView)sender; |
if (grid.IsInEditMode && grid.CurrentCell.ColumnIndex == 1) |
{ |
e.Cancel = true; |
this.radGridView1.ActiveEditor.Value = this.radGridView1.CurrentCell.Value; |
MessageBox.Show("Picking more than available."); |
} |
} |
validating = false; |
} |
} |
catch { } |
} |
Don't hesitate to write us if you have any other questions.
Best wishes,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.