Get Deleted Item in ItemChanging event of BindingList

前端 未结 5 1182
生来不讨喜
生来不讨喜 2020-12-29 22:23

I am using Binding List in my application along with ItemChanged event.

Is there any way I could know the previous values of properties in ItemChanged event. Curren

5条回答
  •  无人及你
    2020-12-29 22:44

    In the specific case you're using this BindingList with a DataGridView, you can use the UserDeletingRow event from the datagrid, where:

    private void myGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
    {
        ItemType DeletedItem = (ItemType)e.Row.DataBoundItem;
    
        //if you want to cancel deletion
        e.Cancel = true;
    }
    

提交回复
热议问题