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
965
RowUpdate Events when a form is closing
posted

I am using Infragistics 12.1. I have a few textboxes and WinGrids on a form that are in a MdiTab. The WinGrids have BeforeRowUpdate and AfterRowUpdate events attached to them and the UpdateMode Property is set to OnRowChangeOrLostFocus.

If I make a change to a grid and then select another row, grid, or textbox the RowUpdate Events fire.  The events do not fire if I close the MdiTab by clicking the X on the tab or via a toolbar icon that programatically closing the form via this.Close()

In the for FormClosing event I've added the following code which will fire off the RowUpdate Events if the data has been changed.

if (this.ugGrid1.ActiveRow != null)
{
 this.ugGrid1.ActiveRow.Update();
}

if (this.ugGrid2.ActiveRow != null)
{
 this.ugGrid2.ActiveRow.Update();
}

if (this.ugGrid3.ActiveRow != null)
{
  this.ugGrid3.ActiveRow.Update();
}
 

Is the above code the perferred way to handle this situation and is it correct that the Grid doesn't lose focus when a toolbar icon or Mdi Tab is closed?

  • 469350
    Verified Answer
    Offline posted

    Hi,

    Yes, this is correct behavior. The grid commits any pending changes when you activate a new row or the grid loses focus.

    Toolbar buttons and the close button don't trigger this update, because they don't take focus.

    What you are doing here is a good way to handle it. You could also call the UpdateData method on the grid, which will update all rows with pending changes, instead of just the ActiveRow.