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
575
Activating the the current cell in _AfterCellUpdate event
posted

I need to activate the current cell in the _AfterCellUpdate event after the error message is shown to tell the user that the value of the cell is wrong.  But the next cell is activated when the tab is pressed.

The code below shows that I am doing everything to keep the focus on the same cell, but the focus is moved to the next cell!


        void ultraGridUM_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {
            if (e.Cell.Column.Key == "Code" && e.Cell.Value!=null)
            {
                foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.ultraGridUM.Rows)
                {
                    if (row != e.Cell.Row)
                    {
                        if (row.Cells["Code"].Value != DBNull.Value)
                        {
                            if (String.Compare(row.Cells["Code"].Value.ToString(), e.Cell.Value.ToString().Trim()) == 0)
                            {
                                MessageBox.Show("Wrong value.");
                                e.Cell.Value = e.Cell.OriginalValue;
                                this.ultraGridUM.ActiveRow = e.Cell.Row;
                                this.ultraGridUM.ActiveCell = e.Cell;
                                this.ultraGridUM.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode,false,false);
           
                                return;
                            }
                        }
                    }
                }
            }
        }

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    The best thing to do would be to validate the cell before it it updated, instead of after. Use BeforeCellUpdate and you can cancel the operation and keep the focus in the cell, instead of trying to put it back in after the user already left.

Children