Unhandled Exception: Not able to BeginEdit, EditItem is already set

Hello, I'm having an intermittent problem with a user of my product where she will get an unhandled exception that crashes the app. I have an event-handler on the AppDomain.CurrentDomain.UnhandledException event, and I'm able to log the exception, but can't figure out where it's coming from.

There are 2 different stack traces that I get, one that appears to be keyboard-related and one mouse-related. The stack traces are below, notice that it doesn't seem to have any of my code in it, except for the initial call to App.Run(). Any suggestions?

System.InvalidOperationException: Not able to BeginEdit, EditItem is already set
   at Syncfusion.Data.CollectionViewAdv.EditItem(Object item)
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.BeginEdit()
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.HandleKeyNavigation(KeyEventArgs args, RowColumnIndex rowColumnIndex)
   at Syncfusion.UI.Xaml.Grid.GridSelectionController.ProcessKeyDown(KeyEventArgs args)
   at Syncfusion.UI.Xaml.Grid.GridSelectionController.HandleKeyDown(KeyEventArgs args)
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.OnPreviewKeyDown(KeyEventArgs e)
   at System.Windows.UIElement.OnPreviewKeyDownThunk(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at My.App.Main()

and

System.InvalidOperationException: Not able to BeginEdit, EditItem is already set
   at Syncfusion.Data.CollectionViewAdv.EditItem(Object item)
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.BeginEdit()
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.ProcessOnTapped(MouseButtonEventArgs e, RowColumnIndex currentRowColumnIndex)
   at Syncfusion.UI.Xaml.Grid.GridSelectionController.ProcessOnTapped(MouseButtonEventArgs e, RowColumnIndex currentRowColumnIndex)
   at Syncfusion.UI.Xaml.Grid.GridSelectionController.HandlePointerOperations(GridPointerEventArgs args, RowColumnIndex rowColumnIndex)
   at Syncfusion.UI.Xaml.Grid.DataColumnBase.OnTapped(MouseButtonEventArgs e)
   at Syncfusion.UI.Xaml.Grid.GridCell.OnMouseUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at My.App.Main()

15 Replies

JG Jai Ganesh S Syncfusion Team March 30, 2018 05:34 AM UTC

Hi Cliffe,  
 
We are unable to reproduce the reported exception in our side. We had thrown the exception externally in our source while call the BeginEdit method before end the edit action of previous editing item.  
 
  1. Please share the complete call stack for this issue (In your given stack trace its have current edit item only , so from the complete call stack only we could see the flow on what was the EditItem is not yet ended).
  2. Please share the exact replication procedure of this exception
Regards,  
Jai Ganesh S


CH Cliffe Hodgkinson April 11, 2018 12:53 PM UTC

Hello, and thanks for your reply.

Unfortunately, this problem is intermittent - I haven't been able to determine the steps to reproduce it.

What I've shown is the stack trace of the exception that gets thrown. I'm not sure how I could go about getting more detailed information - can you tell me how I can do that?

Thanks,
Cliffe


PM Paul Meems April 12, 2018 09:18 AM UTC

I'm having the same issue.
I'm creating a WinForms application with a barcode scanner.
The scanner puts its value in a textbox. OnKeyDown I check for Enter (send by the barcode scanner).
Then I look up the price of the article in a database and show its properties in the datagrid.
This works fine. But the user can also change the price of the article.
When it goes to a record and changes the price, this works fine. But when it changes a second row I get the error "Not able to BeginEdit, EditItem is already set"

I already looked at this post: https://www.syncfusion.de/forums/135394/focus-on-datagrid and tried to implement sfDataGrid1.View.CommitEdit() in sfDataGrid1_CurrentCellActivated(...). But that didn't help.

I've implemented sfDataGrid1_CurrentCellEndEdit() because after the change I need to set the focus back to my initial textbox so my barcode scanner can continue.

Most likely my workflow is not optimal. Please advice improvements.



JG Jai Ganesh S Syncfusion Team April 12, 2018 12:38 PM UTC

Hi Cliffe, 
 
As we already said that the reported issue was not reproduced in our side. We have thrown this error message (” Not able to BeginEdit, EditItem is already set”) externally in our source when multiple cell is in edit mode. So, it seems you have tried to edit the cell when other cell is in edit mode in your application. Hence this error message thrown.  Could you please let us know in which action you made in your application before going to edit mode and also whether you are customizing anything to begin edit the cell.  
 
Could you please share our requested information and based on that we could proceed to analyze the reported issue further from our end. In the meantime, we could also check the feasibility to overcome this issue and update you the details. 
 
Regards, 
Jai Ganesh S


PM Paul Meems April 12, 2018 01:28 PM UTC

I have more or less hijacked this thread because I'm having the same problems.
I don't know Cliffe and I don't know his use-case but I can tell you mine.

I'm working on a very simple cash register:

The textbox with the Barcode label is getting the barcode from my barcode scanner.
On the KeyDown event I check for the Enter key and then get the product from my SQLite database based on the barcode:
        private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData != Keys.Enter) return;

            var product = SqliteService.GetProductByBarcode(txtBarcode.Text) ??
                          new Product {Barcode = txtBarcode.Text, Price = 1};
            AddToOrder(product);
        }
This product is added to the datagrid:
        private void AddToOrder(Product product)
        {
            var orderline = _order.OrderLines.FirstOrDefault(x => x.Barcode == product.Barcode);
            if (orderline == null)
            {
                _order.OrderLines.Add(SqliteService.ProductToOrderLine(product));
            }
            else
            {
                orderline.Amount++;
            }

            txtBarcode.Text = string.Empty;
            txtBarcode.Focus();

            _totalAmountOrder++;
            lblTotalAmountOrder.Text = _totalAmountOrder + @" stuks";
            _totalPriceOrder += product.Price;
            SetLblTotalPriceOrder();
        }

Order and OrderLines are defined as:
    public class Order: IDisposable
    {
        public int Id { get; set; }
        public DateTime CreatedAt { get; set; }
        public double TotalPrice { get; set; }
        public ObservableCollection<OrderLine> OrderLines { get; set; }

        public Order()
        {
            CreatedAt = DateTime.Now;
            OrderLines = new ObservableCollection<OrderLine>();
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool isdisposable)
        {
            OrderLines?.Clear();
        }
    }

    public class OrderLine : INotifyPropertyChanged
    {
        private double _price;
        private string _name;
        private int _id;
        private int _productId;
        private string _barcode;
        private int _amount;

        [Display(AutoGenerateField = false)]
        public int Id
        {
            get { return _id; }
            set
            {
                if (value == _id) return;
                _id = value;
                OnPropertyChanged(nameof(Id));
            }
        }

        public int ProductId
        {
            get { return _productId; }
            set
            {
                if (value == _productId) return;
                _productId = value;
                OnPropertyChanged(nameof(ProductId));
            }
        }

        [Display(Name = "Name")]
        public string Name
        {
            get { return _name; }
            set
            {
                if (value == _name) return;
                _name = value;
                OnPropertyChanged(nameof(Name));
            }
        }

        [Display(Name = "Prijs")]
        public double Price
        {
            get { return _price; }
            set
            {
                if (value.Equals(_price)) return;
                _price = value;
                OnPropertyChanged(nameof(Price));
            }
        }

        public string Barcode
        {
            get { return _barcode; }
            set
            {
                if (value == _barcode) return;
                _barcode = value;
                OnPropertyChanged(nameof(Barcode));
            }
        }

        [Display(Name = "Aantal")]
        public int Amount
        {
            get { return _amount; }
            set
            {
                if (value == _amount) return;
                _amount = value;
                OnPropertyChanged(nameof(Amount));
            }
        }

        // Navigation
        public Order Order { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

When the big 'Nieuw' (New) button is clicked. The form is reset, the order is saved to the database and the datagrid source is reset:
        private void newOrder()
        {
            ResetForm();
            SaveOrder();
            _order = new Order();
            sfDataGrid1.DataSource = _order.OrderLines;
        }

Because it is possible the price in the database is not right or the product wasn't found in the database, the user must be able to change the price in the datagrid.
In order to let the barcode scanner work correctly, the focus needs to be in the textbox. So when the price is edited (making the datagrid have the focus) I need to move the focus.
I do this using CurrentCellEndEdit:
        private void sfDataGrid1_CurrentCellEndEdit(object sender, Syncfusion.WinForms.DataGrid.Events.CurrentCellEndEditEventArgs e)
        {
            _totalPriceOrder = _order.OrderLines.Sum(x => x.Amount * x.Price);
            SetLblTotalPriceOrder();

            sfDataGrid1.SelectedIndex = -1;
            txtBarcode.Focus();
        }

That is all I do.
These are my settings:
            this.sfDataGrid1.AccessibleName = "Table";
            this.sfDataGrid1.AllowResizingColumns = true;
            this.sfDataGrid1.AllowResizingHiddenColumns = true;
            this.sfDataGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.sfDataGrid1.AutoSizeColumnsMode = Syncfusion.WinForms.DataGrid.Enums.AutoSizeColumnsMode.Fill;
            this.sfDataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.sfDataGrid1.LiveDataUpdateMode = Syncfusion.Data.LiveDataUpdateMode.AllowSummaryUpdate;
            this.sfDataGrid1.Location = new System.Drawing.Point(38, 138);
            this.sfDataGrid1.Name = "sfDataGrid1";
            this.sfDataGrid1.Size = new System.Drawing.Size(677, 337);
            this.sfDataGrid1.TabIndex = 5;
            this.sfDataGrid1.Text = "sfDataGrid1";
            this.sfDataGrid1.CurrentCellEndEdit += new Syncfusion.WinForms.DataGrid.Events.CurrentCellEndEditEventHandler(this.sfDataGrid1_CurrentCellEndEdit);

Please advise what to do.
Thanks, Paul.



JG Jai Ganesh S Syncfusion Team April 13, 2018 12:49 PM UTC

Hi Paul,  
 
Thanks for your response.  
 
We have checked the reported issue “Not able to BeginEdit, EditItem is already set” on our end, but the reported issue is not reproduced on our end. As per your application we have created the sample for testing, we have get the value from the text box and added into SfDataGrid while press the enter key. And if the focus in SfDataGrid for edit the “Price” column we have set the focus to text box after current cell gets end edit. All the process is works fine on our end.  
Please refer the below sample which we are tried to reproduce the issue,    
 
 
If still you have faced the issue could please revert by modifying the attached sample based on your application along with the replication procedure, please share your application if it is possible. It will be helpful for us to analyze further.     
 
Regards,    
Jai Ganesh S 



PM Paul Meems April 13, 2018 01:39 PM UTC

Thanks for the sample. Like you I can't reproduce my problem with it.

I had a good look at my code, removed all events except for the text-keydown and grid-EndEdit and still had the problem.
Did an even closer look at noticed I had this line in my EndEdit:
sfDataGrid1.SelectedIndex = -1;

After removing this line I can't reproduce the problem anymore.

I tried adding the line to your code but still can't reproduce it anymore.

I'm not sure what happened but it looks like the problem had vanished. I will do some more testing and get back to you when the problem reappears.

Thanks,
Paul



JG Jai Ganesh S Syncfusion Team April 16, 2018 07:34 AM UTC

Hi Paul, 
 
Thank you for the update. Please get back to us once you were able to reproduce the issue and we will be happy to assist you. 
 
Regards, 
Jai Ganesh S 



ZI Zia November 19, 2024 11:50 AM UTC

Hi,


Is there any way to suppress or workaround this error? For me it happens so rarely so it is almost impossible to reproduce and debug it.


Thanks,

Zia

Not able to BeginEdit, EditItem is already set

System.InvalidOperationException: Not able to BeginEdit, EditItem is already set
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.BeginEdit()
   at Syncfusion.UI.Xaml.Grid.DataColumnBase.OnTapped(MouseButtonEventArgs e)
   at Syncfusion.UI.Xaml.Grid.GridCell.OnMouseUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Atlas.Euribor.App.Main() System.Object:





MS Malini Selvarasu Syncfusion Team November 20, 2024 12:26 PM UTC

Hi Zia,

Based on the information provided, we understand that you encountered the exception “Not able to BeginEdit, EditItem is already set.” To investigate, we created a simple sample to replicate the issue but were unable to reproduce the problem. On our end, the exception was not triggered when tapping the cell for editing. For your reference, we have attached the sample and a video.  

If you continue to experience the issue, kindly provide us with the following additional details to assist further:   
1. **Custom Modifications**: Have you made any customizations to the SfDataGrid in your application? If so, please share the details.  
2. **Templates**: Are you using any templates for your columns? If so, please provide the relevant details.  
3. **Video**: Share a video demonstrating the issue along with detailed steps to reproduce the problem.  
4. **Modified Sample**: Modify the attached sample to replicate the issue on your end and share it with us.  
These details will help us better understand the problem and work toward a timely solution. 
Note: Regarding your request to suppress or work around this error, the exception *“Not able to BeginEdit, EditItem is already set”* is triggered intentionally in our source when multiple cells are simultaneously in edit mode. If an attempt is made to edit a cell while another cell is already in edit mode, this error will be raised. Unfortunately, this behavior cannot be bypassed or suppressed at the sample level. We recommend ensuring that the edit session for one cell is completed or canceled before initiating editing in another cell. Thank you for your cooperation.
Regards,
Malini Selvarasu

Attachment: SfDataGrid_Demo_582bea5d.zip


ZI Zia February 11, 2025 12:02 PM UTC

I have managed to reproduce the problem in a sample application (attached)

The sample application contains two datagrids where:

  • Values are periodically updating.
  • Rows are periodically added and removed from each datagrid.

Steps to reproduce:
  1. Open the application, you should see values updating
  2. Click on and edit values in the alpha columns in the first table. You may need to click on lots of cells and type numbers very rapidly. As quickly as you can.
  3. At some point the application will crash. You should be able to achieve this in under 10 seconds.


The error looks like this:

Application: DataGridExample.exe

CoreCLR Version: 6.0.3324.36610
.NET Version: 6.0.33
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException: Not able to BeginEdit, EditItem is already set
   at Syncfusion.Data.CollectionViewAdv.EditItem(Object item)
   at Syncfusion.UI.Xaml.Grid.GridCurrentCellManager.BeginEdit()
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.OnTextInput(TextCompositionEventArgs e)
   at System.Windows.UIElement.OnTextInputThunk(Object sender, TextCompositionEventArgs e)
   at System.Windows.Input.TextCompositionEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.TextCompositionManager.UnsafeCompleteComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.TextCompositionManager.UnsafeStartComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessTextInputAction(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at DataGridExample.App.Main()

Attachment: DataGridExample_2acae17a.zip


MS Malini Selvarasu Syncfusion Team February 12, 2025 02:03 PM UTC

Hi Zia,

Thank you for sharing the sample and reproduction steps. We have successfully replicated the issue and require some time to validate it. We will provide further updates on February 14, 2025. We appreciate your patience in the meantime.
Regards,
Malini Selvarasu


MS Malini Selvarasu Syncfusion Team February 14, 2025 02:35 PM UTC

Hi Zia,

Based on the information provided, we understand that you encountered an exception while editing a cell. Upon reviewing the provided sample, we noticed that data is continuously updated while attempting to edit the cell simultaneously. Since `dataGrid.View.EditingItem` is set to `true`, an invalid operation occurs when the "Alpha" column value is updated while the editing process is still active. As a result, the edit item is not removed properly, leading to an **Unhandled Exception: "Not able to BeginEdit, EditItem is already set."**  
To resolve this issue, we recommend updating the data values **only when** `dataGrid.View.EditingItem` is set to `false`. This approach ensures that the exception does not occur. We have modified the sample to demonstrate this solution. Please review it and let us know if it resolve your issue.
Regards,
Malini Selvarasu

Attachment: DataGridExample_dfe8008e.zip


ZI Zia February 17, 2025 11:29 AM UTC

Hi,

I have reviewed the sample solution. Although the error doesn't occur anymore, it doesn't really fit my use case.

In my case you can assume the values of Alpha are important real-time data being fed into the datagrid. I have simulated this in my example by including a Task on each RowData which changes the value of Alpha periodically.

If the value of Alpha changes, it must be shown on the datagrid. However in your example, you are just abandoning updating the value of Alpha because the grid is in edit mode. This would result in the datagrid showing stale data in my use case.




MS Malini Selvarasu Syncfusion Team February 18, 2025 02:16 PM UTC

Hi Zia,

The issue occurs when LiveDataUpdateMode is enabled because data updates and sorting happen simultaneously. During this process, the edited item is not properly removed from the view, which is a limitation of LiveDataUpdateMode.
To avoid this, we recommend updating the data at runtime without modifying the sorting order. Disabling LiveDataUpdateMode ensures that edited data is correctly reflected while maintaining consistent grid behavior.
We also tested this scenario in MS DataGrid, where data updates did not affect the sorting order, preventing any issues during editing. A video demonstrating this behavior is attached for your reference.
Thank you for your understanding.
Regards,
Malini Selvarasu

Attachment: Video_Reference_e1d4b007.zip

Loader.
Up arrow icon