Home Forums WPF controls Xceed DataGrid for WPF Event when Row has been succesfully validated?

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

    Hi all,

    I have a DataGrid with an InsertionRow and ValidationMode=”RowEndingEdit”. My ItemsSource implements IBindingList.

    My question is whether the DataGrid or the InsertionRow fires an Event when the data in the InsertionRow has been validated, and thus added to the DataGrid? I would like to catch that event and add the validated data to my database.

    Thanks in advance,
    Frances

    Imported from legacy forums. Posted by Frances (had 5806 views)

    User (Old forums)
    Member
    Post count: 23064

    * bumpie *

    Imported from legacy forums. Posted by Frances (had 555 views)

    Xceed Support
    Member
    Post count: 5658

    There are currently no events that notify you when the content of a row has been edited/validated.

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

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

    thanks for your reply. Do you maybe know of a work-around I could use?

    Thanks,
    Frances

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

    Xceed Support
    Member
    Post count: 5658

    You could try deriving and overriding EndEdit.

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

    User (Old forums)
    Member
    Post count: 23064

    Fast reply! 🙂

    You mean creating my own InsertionRow? I’ll give that a try and let you know how it goes.

    Thanks,
    Frances

    Imported from legacy forums. Posted by Frances (had 500 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve got a working implementation, it looks like this:

    The custom InsertionRow

    class CustomInsertionRow : InsertionRow
    {
    public event EventHandler EndingEdit;

    public override void EndEdit()
    {
    try
    {
    base.EndEdit();
    }
    catch (Exception)
    {
    return;
    }

    OnEndingEdit(this, EventArgs.Empty);
    }

    public void OnEndingEdit(Object sender, EventArgs args)
    {
    if (EndingEdit != null)
    {
    EndingEdit(this, args);
    }
    }
    }

    The implementation of the CustomInsertionRow links to the event:

    <local:CustomInsertionRow ReadOnly="False" Background="AliceBlue" Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(TextElement.Foreground)}" EndingEdit="InsertionRowEndingEdit"></local:CustomInsertionRow>

    In the EventHandler for EndingEdit I can retrieve the last row added to the DataGrid and save that to my database.

    Thanks for all the help!
    Frances

    Imported from legacy forums. Posted by Frances (had 7959 views)

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