开发者

Code to save on row change using bindingNavigator, bindingSource

开发者 https://www.devze.com 2022-12-27 14:58 出处:网络
When using a bindingNavigator and bindingSource and clicking a move button or add button or delete button, the bindingSource completes its action code before the click handler of the button (i.e. user

When using a bindingNavigator and bindingSource and clicking a move button or add button or delete button, the bindingSource completes its action code before the click handler of the button (i.e. user code)

This prevents a save action on the row change. I'd like to find a bindingSource hook, something like 'befo开发者_如何学PythonreRowChange'.

I can subclass the bindingSource and get ahead of the add or remove event but that doesn't cover all the row move actions.

Any clues, suggestions welcome.


The BindingNavigator has a property called 'DeleteItem'. Change this property from 'BindingNavigatorDeleteItem' to '(none)'.

private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
  if ( bindingSource.Count > 0 )
  {
    if (MessageBox.Show("Confirm Delete?", "Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
    {
      bindingSource.RemoveCurrent();
    }
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消