Cancel or suspend AfterCellUpdate method in grid

rated by 0 users
This post has 1 Reply | 2 Followers

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

 Sorry for the duplicate post, I originally put this in the general questions, then noticed this forum which is more appropriate.

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

Top 100 Contributor
Points 873
Infragistics Employee

Hi,

 You should be able to use the EventManager of the UltraGrid to do this...

 suspend the event before your call to the loop as follows:

TransportationGrid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.GridEventIds.AfterCellUpdate, false);

and then turn it back on passing true as the second value to the SetEnabled method of the Grid's Event Manager afterwards.

Matthew Kraft
Corporate Trainer
Infragistics, Inc.

Page 1 of 1 (2 items) | RSS

Forum Statistics

19,646 users have contributed to 78,509 threads and 87,118 posts.

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

In the past 24 hours, we have 4 new thread(s), 6 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 RoyAlmon.