Cancel or Suspend the AfterCellUpdate method of a grid

rated by 0 users
This post has 2 Replies | 3 Followers

Not Ranked
Points 155
cesafsky Posted: 02-11-2008 2:32 PM

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);
    
}
   }
}

Not Ranked
Points 50

Use the beforeCellUpdate method to set the SourceContactID, loading time, ArrivalTime, ArrivalDate

Steve
  • | Post Points: 20
Top 10 Contributor
Points 140,053
Infragistics Employee

 You can use the EventManager to disable the event while you are in it.

Something like this:

grid.EventManager.SetEventEnabled(GridEventIds.AfterCellUpdate, false) 

try

{

    // Your code here 

}

finally

{

    grid.EventManager.SetEventEnabled(GridEventIds.AfterCellUpdate, true)

Mike Saltzman

R&D Engineer

Infragistics, Inc.

  • | Post Points: 5
Page 1 of 1 (3 items) | RSS

Forum Statistics

19,640 users have contributed to 78,505 threads and 87,114 posts.

In the past week, we've had 1,434 new users, adding to our total of 423,240 registered users!

In the past 24 hours, we have 22 new thread(s), 65 new post(s), and

In the past 3 days, the most popular thread for everyone has been "UltraGrid - ConditionAppearanceRow". The post with the most views is "Re: A gripe about support and sample projects". The most replies were made to "A gripe about support and sample projects".

Please welcome our newest member paig.