New to Telerik UI for WinForms? Start a free 30-day trial
Validation
Updated over 1 year ago
| RELATED VIDEOS |
|---|
| Validation with RadGridView for WinForms In this video you will learn how to use the event-based Validation functionality in RadGridView for WinForms. Learn how to use the CellValidating and RowValidating events to ensure user input is valid. (Runtime: 08:47) |
To prevent invalid input, wire the ValueChanging and ValueChanged events of the grid and add custom validation logic. Below is a simple example that demonstrates how to reject strings longer than 10 characters:
Handling the value changed event
C#
void radGridView1_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e)
{
if (e.NewValue.GetType() == typeof(string))
{
if (e.NewValue.ToString().Length > 10)
{
{
e.Cancel = true;
}
}
}
}