Home Forums WPF controls Xceed DataGrid for WPF CanCancel has no effect on Items_CurrentChanging event

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23558 |

    I want to capture the Items_CurrentChanging event in the hope of intercepting the row change to cancel the row selection if data is invalid. When the Items_CurrentChanging event is fired, the grid.CurrentItem already contains the object of the clicked on row so it seems the grid has already navigated to the new row before the CurrentChanging event has been fired. If you set e.Cancel = true, it has no effect because the old row is no longer highlighted [active].

    Any thoughts?

    Thanks.

    Imported from legacy forums. Posted by Mark (had 7817 views)

    User (Old forums)
    Member
    Post count: 23064

    If all you want to do is Validate the row then you could use A CellValidationRule

    Imported from legacy forums. Posted by MiddleTommy (had 568 views)

    User (Old forums)
    Member
    Post count: 23064

    and set the grid.ValidationMode = ValidationMode.RowEndingEdit;

    Imported from legacy forums. Posted by MiddleTommy (had 538 views)

    User (Old forums)
    Member
    Post count: 23064

    That’s really not what we want to do. We are using a separate data validation from a Business Object provider called CSLA. We are using the list as a driver for a details area that has more information than what’s showing in the grid. That details area has editable items. What we want is if you edit the details area and the data you entered is invalid we don’t want you to be able to navigate off that item.

    So, we need a way to cancel the selection and the CurrentChanging event seems like the right place…

    Is this a bug or by design?

    Imported from legacy forums. Posted by Mark (had 533 views)

    User (Old forums)
    Member
    Post count: 23064

    It is most likely a bug

    maybe work around it by
    keeping a reference to the current item to reset the selected item

    pseudo example:

    private YourObjectSource currentItem;
    private void current_Item_changing(…)
    {
    if(YourDataIsValid)
    {
    currentItem = newCurrentItem;
    }
    else
    grid.currentitem = currentItem;
    }

    Imported from legacy forums. Posted by MiddleTommy (had 511 views)

    User (Old forums)
    Member
    Post count: 23064

    you might have to set some flags like
    bool ResettingCurrentItem;

    to avoid a possible continuous loop;

    so new pseudo example:

    private YourObjectSource currentItem;
    bool ResettingCurrentItem = false;
    private void current_Item_changing(…)
    {if(!ResettingCurrentItem )
    {if(YourDataIsValid){currentItem = newCurrentItem;}
    else{ResettingCurrentItem =true;grid.currentitem = currentItem;ResettingCurrentItem =false;}
    }
    }

    Imported from legacy forums. Posted by MiddleTommy (had 444 views)

    User (Old forums)
    Member
    Post count: 23064

    This might be a bug, I’ll need to investigate a bit more… I’ll follow-up in this thread.

    Thanks,

    Imported from legacy forums. Posted by Pascal (had 1066 views)

    User (Old forums)
    Member
    Post count: 23064

    Any word on a fix for this? I would be great to get it working…

    Imported from legacy forums. Posted by Mark (had 810 views)

    Xceed Support
    Member
    Post count: 5658

    Pascal is currently on vacation. I am sure that he will provide an update in this thread as soon as he can. Thank you for your patience.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 527 views)

    User (Old forums)
    Member
    Post count: 23064

    Is Pascal back from his long vacation yet? Thanks!

    Imported from legacy forums. Posted by Mark (had 491 views)

    User (Old forums)
    Member
    Post count: 23064

    I have the same problem like yours. Do you have any solution to solve it?
    (Is Pascal back from his long vacation yet…………………………)

    Imported from legacy forums. Posted by RayYu (had 588 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve been back from vacation for a while now, sorry to have not followed-up earlier.

    Indeed, this is a bug. We intend to enhance currency management in the grid, but it may not make it in time for the next release…

    Pascal

    Imported from legacy forums. Posted by Pascal (had 886 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi, are there any plans to fix this bug in near future?

    Reason is that we also need this feature very urgently, we are currently evaluating Datagrid for a big WPF project, and without this bug fixed buying the grid does not make any sense…

    Heard that the next release of Datagrid control is going to be published end of January / Mid of February, and beneath other urgent things (Master-Detail view capabilities) this bug fix should go into that release…

    Imported from legacy forums. Posted by Wilfried (had 8499 views)

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.