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
155
Cancel or Suspend the AfterCellUpdate method of a grid
posted

My main question is this... is there a way to "Cancel" or "Suspend" the grid so when I update a column the "AfterCellUpdate" method will not be called? 

I have a windows ultragrid (using 2007 V1), and I have logic in the "AfterCellUpdate" method that is causing me headaches!

Inside the method, I call another method that is outside this UI project.  When a user changes the value of the "Destination", "Origination" or "Loading Time" column, I have to call a method to calculate an "Arrival Time".

Example   The Loading Time column in a row is set to 4:00 PM the Origination column is New York and the Destination column is Atlanta.

The user changes the Loading Time to 3:00, and the Origination column to Minneapolis. I need to call my outside method to recalculate the Arrival Time...  what is happening is that I create a loop in my "AfterCellUpdate" method because I update the Loading Time column (because the date part of that column could change because of the other updates).

Thanks in advance!

Below is my method... I will BOLD the part that loops.

private void TransportationGrid_AfterCellUpdate(object sender, CellEventArgs e)
{
   MarketLoadRecord marketLoadRecord = null;
  
UltraGridCell activeCell = TransportationGrid.Grid.ActiveCell;

   string sourceProductionTypeID = string.Empty;
  
string destinationProductionTypeID = string.Empty;

   if (activeCell != null)
   {
     
try
     
{
        
switch (activeCell.Column.Key)
         {
           
case "Origination":
           
//update the TransportationGrid with data from the source SITE dropdown

                 activeCell.Row.Cells["SourceContactID"].Value = _dropDownGridRow.Cells["SiteContactID"].Value;

                 //call method to update the arrival time
                 marketLoadRecord = SetArrivalTime();
                 if (marketLoadRecord != null)
                 {
                     //right here is where it loops.  As soon as I set the ["LoadingTime"].Value , it fallse right back into the top of this method

                     TransportationGrid.Grid.ActiveRow.Cells["LoadingTime"].Value = marketLoadRecord.LoadingTime;
                     TransportationGrid.Grid.ActiveRow.Cells[
"ArrivalTime"].Value = marketLoadRecord.ArrivalTime;
                     TransportationGrid.Grid.ActiveRow.Cells[
"ArrivalDate"].Value = marketLoadRecord.ArrivalDate;                 
 
                
}

                 break;

          }
    
}
    
catch (Exception ex)
     {
         
MessageBox.Show(ex.Message, "TransportationGrid_AfterCellUpdate Error", MessageBoxButtons.OK);
    
}
   }
}