开发者

Code to save on row change using bindingNavigator, bindingSource

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜