Dela via


DataRepeater.CancelEdit Method

Allows users to cancel an edit to the current child control in the current DataRepeaterItem.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
Public Sub CancelEdit
public void CancelEdit()
public:
void CancelEdit()
member CancelEdit : unit -> unit 
public function CancelEdit()

Remarks

Use this method to enable users to cancel their changes to child controls in a DataRepeater control. You must monitor the KeyDown events for the child controls to determine when the user has pressed the ESC key and call the CancelEdit method to return the control to its pre-edit state.

Examples

The following example demonstrates how to cancel an edit when the user presses the ESC key. It assumes that you have a form that contains a DataRepeater control named DataRepeater1 that contains a TextBox named ProductNameTextBox.

Private Sub ProductNameTextBox_KeyDown(
    ByVal sender As Object, 
    ByVal e As System.Windows.Forms.KeyEventArgs
  ) Handles ProductNameTextBox.KeyDown

    If e.KeyCode = Keys.Escape Then
        DataRepeater1.CancelEdit()
    End If
End Sub
private void productNameTextBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    if (e.KeyCode == Keys.Escape)
    {
        dataRepeater1.CancelEdit();
    }
}

.NET Framework Security

See Also

Reference

DataRepeater Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the DataRepeater Control (Visual Studio)