We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cancel Row Insert

Thread ID:





43529 Apr 25,2006 03:44 PM UTC Apr 26,2006 05:35 AM UTC WinForms 1
Tags: GridControl
Chad Elliot
Asked On April 25, 2006 03:44 PM UTC

I’ve got a GridDataBoundGrid and I need to simulate the Before Insert event in Microsoft Access. To do this, I need to know when a new record is being added to the grid and have the ability to cancel the adding of the new record. I have tried using RowEditing event of the data grid, but setting e.cancel = true only cancels the text that was entered into the cell, it does not remove the row just inserted. I tried multiple variations using MyDataGrid.CurrentCell.CancelEdit, MyDataGrid.CurrentCell.EndEdit, MyDataGrid.Binder.CancelEdit, and MyDataGrid.Binder.EndEdit, but nothing gets rid of the new row. So far, the best I have come up with is set e.cancel = true and move the current cell to the previous row. Private Sub MyDataGrid_RowEditing(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowEventArgs) Handles MyDataGrid.RowEditing If e.IsAddNew = True Then e.Cancel = True MyDataGrid.CurrentCell.MoveTo(e.RowIndex - 1, MyDataGrid.CurrentCell.ColIndex) End If End Sub The problem with this code is that the row I moved to now is in a state of editing (the row header has the pencil icon instead of the arrow icon). Is there a way to change the row state or is there a better way to cancel the inserting of a new row?

Administrator [Syncfusion]
Replied On April 26, 2006 05:35 AM UTC

Hi Chad, One simple way to cancel the inserting new row is by just sending the Esc key to the grid twice. Below is a code snippet in a button click event handler. If using the button click event to send the keys then, make sure to set the CausesValidation property of the button to False. Let us know if this helps. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.GridDataBoundGrid1.Focus() SendKeys.Send("{Esc}") SendKeys.Send("{Esc}") End Sub Regards, Calvin.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon