Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Retrieve a field which has been deleted
posted

Hello guys,

I have an UltraGrid with many rows/columns.
I add a button to delete the row we have selected (n.b.: It must be possible to delete one or several rows).

Here's the code that I have for the deletion :

private void DeleteButton_Click(object sender, EventArgs e)
{
   // Check if there are any selected rows.
   if (this.CVaultGridExcludes.Selected.Rows.Count > 0)
   {
      // Delete the selected rows by calling DeleteSelectedRows.
      this.CVaultGridExcludes.DeleteSelectedRows();
   }
   else
   {
      // Show a message if there are no selected rows.
      MessageBox.Show("There are no rows selected. Select rows first.");
   }
}

I'd like to know how to store/retrieve the rows which have been chosen to be deleted in order to know what I have to modify in my DB.

I thought use an event such as AfterRowDeleted.

Or compare what I have in my DB and what I have in my UltraGrid and delete all rows which do not match.



 

Parents
  • 21795
    Verified Answer
    Offline posted

    Hello Antony,

    Thank you for posting in our forum.

    In order to save the rows, before you delete them, you may use CopyTo method of the RowsCollection. You can use code like this:

    private void DeleteButton_Click(object sender, EventArgs e)

    {

        // Check if there are any selected rows.

        if (this.ultraGrid1.Selected.Rows.Count > 0)

        {

            // Create a new array of rows

            UltraGridRow[] selectedRows = new UltraGridRow[this.ultraGrid1.Selected.Rows.Count];

     

            // Copy selected rows to the array before you delete them

            this.ultraGrid1.Selected.Rows.CopyTo(selectedRows, 0);

                   

            // Delete the selected rows by calling DeleteSelectedRows.

            this.ultraGrid1.DeleteSelectedRows();

        }

        else

        {

            // Show a message if there are no selected rows.

            MessageBox.Show("There are no rows selected. Select rows first.");

        }

    }

    Please, let me know if you need any additional information.

    Thank you for using Infragistics Components.

Reply Children
No Data