Home Forums WPF controls Xceed DataGrid for WPF How do I override EndEdit method in the InsertionRow class?

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

    I need to override EndEdit() method in the InsertionRow class but can’t figure out how to do this. Could you help me?

    Imported from legacy forums. Posted by Alexander (had 3045 views)

    Xceed Support
    Member
    Post count: 5658

    Here is how you can derive from the EndEdit() method from the InsertionRow. It shows how to implement an EndingEdit event.

    e.g.,
    <code>
    //Here is the new InsertionRow
    class MyInsertionRow : InsertionRow
    {
    public MyInsertionRow()
    : base()
    {
    }

    public override void EndEdit()
    {
    CancelEventArgs myCancel = new CancelEventArgs();
    this.OnEndingEdit( this, myCancel );

    if( myCancel.Cancel == true )
    this.CancelEdit();
    else
    base.EndEdit();
    }

    public event CancelEventHandler EndingEdit;

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

    <!–The XAML code where you assign your new InsertionRow:–>
    <xcdg:DataGridControl x:Name=”OrdersGrid”
    ItemsSource=”{Binding Source={StaticResource cvs_orders}}”>
    <xcdg:DataGridControl.View>
    <xcdg:TableView>

    <xcdg:TableView.FixedHeaders>
    <DataTemplate>
    <local:MyInsertionRow EndingEdit=”MyInsertionRow_EndingEdit”/>
    </DataTemplate>
    </xcdg:TableView.FixedHeaders>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>

    //The code behind:
    public partial class Window1 : Window
    {
    public Window1()
    {
    InitializeComponent();
    }

    private void MyInsertionRow_EndingEdit( object sender, System.ComponentModel.CancelEventArgs e )
    {
    MessageBoxResult myResult = MessageBox.Show( “Do you want to cancel this line”, “Cancel ?”, MessageBoxButton.YesNo );

    if( myResult == MessageBoxResult.Yes )
    e.Cancel = true;
    }
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 2399 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you very much!

    Imported from legacy forums. Posted by Alexander (had 2796 views)

    User (Old forums)
    Member
    Post count: 23064

    Can anybody show me how to do override the EndEdit for a normal datarow.

    I think I’m overriding the method correctly, but I don’t know how to bind to the event XAML.

    Imported from legacy forums. Posted by Henry (had 2880 views)

    Xceed Support
    Member
    Post count: 5658

    The above method should work…

    Can you provide the code you have and maybe we can help fill the gaps. [;)]

    Imported from legacy forums. Posted by Marcus [Xceed] (had 992 views)

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