WinForms Cardview Editors Overview
RadCardView supports editing of its content out of the box. This operation can be started by clicking with the mouse on the value of a particular item. This functionality is controlled by the AllowEdit property and by default it is set to true.
The Editors is part of Telerik UI for WinForms, a
professional grade UI library with 160+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
Disable Editing
this.radCardView1.AllowEdit = false;
Me.RadCardView1.AllowEdit = False
Editing Lifecycle
When an item is displayed in RadCardView and the user clicks on the editor of a selected cardview item, the following steps are performed:
The SelectedItem of the control is changed.
The BeginEdit() method is called internally.
The ItemEditing event is fired. The edit operation can be canceled by setting the Cancel event argument to true.
A text box editor appears in the selected item.
When an item is brought out of edit mode, the following steps are performed:
The editor determines if it will handle the keystroke - for example Esc - cancels editing, Enter ends editing and submits changes.
The editor instance performs the action it has defined for the Enter key. Typically this indicates that edit mode should be exited and any changes made during the edit session should be saved.
In response to the action described in the previous step the EndEdit() method is called internally.
The ItemValidating event allows the user to hook up custom logic for verification. If the ValueValidating event does not succeed (e.Cancel is true), ValidationError event is fired to notify all listeners that the validation has failed.
Follows the ItemValueChanging event via which you can cancel assigning a new value to the item.
If the previous event was not canceled, the new value is assigned to the item and the ItemValueChanged event is fired.
The Following example demonstrates the ItemValidating event handling integer values:
Data Validation
private void radCardView1_ItemValidating(object sender, ListViewItemValidatingEventArgs e)
{
int newInt = 0;
if (int.TryParse(Convert.ToString(e.NewValue), out newInt))
{
e.NewValue = newInt;
}
else
{
e.Cancel = true;
}
}
private void radCardView1_ValidationError(object sender, EventArgs e)
{
RadMessageBox.Show("Invalid Value");
}
Private Sub radCardView1_ItemValidating(sender As Object, e As ListViewItemValidatingEventArgs)
Dim newInt As Integer = 0
If Integer.TryParse(Convert.ToString(e.NewValue), newInt) Then
e.NewValue = newInt
Else
e.Cancel = True
End If
End Sub
Private Sub radCardView1_ValidationError(sender As Object, e As EventArgs)
RadMessageBox.Show("Invalid Value")
End Sub
Telerik UI for WinForms Additional Resources
- Telerik UI for WinForms Product Overview
- Telerik UI for WinForms Blog
- Telerik UI for WinForms Videos
- Telerik UI for WinForms Roadmap
- Telerik UI for WinForms Pricing
- Telerik UI for WinForms Code Library
- Telerik UI for WinForms Support
- What’s New in Telerik UI for WinForms