Edit this page


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

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;

Private Sub RadGridView1_ValueChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.ValueChangingEventArgs) Handles RadGridView1.ValueChanging
    If e.NewValue.GetType() Is GetType(String) Then
            If e.NewValue.ToString().Length > 10 Then
                If True Then
                    e.Cancel = True
                End If
            End If
        End If
    End Sub

See Also

Was this article helpful? Yes No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article