工作导航器 [英] Working Navigator

查看:103
本文介绍了工作导航器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

使用AddNew和Delete按钮,没有像SaveData按钮看到的事件代码,我想说的是,如果我想在保存数据语句之前调用某个函数你可以这样做,但删除并添加新的未显示的事件处理程序,以通过某些语句预编码
作为保存按钮,那么如何在AddNew或删除按钮事件处理程序之前添加一些语句?

With AddNew and Delete buttons no event code visible like SaveData button ,what i want to say that if i want to call some function before saving data statements you can do that but with delete and add new the event handlers not shown to you to precode it by some statements as save button ,so how can i add some statements before AddNew or Delete buttons event handlers fired?

谢谢

推荐答案

有几个步骤。首先删除删除按钮的默认处理程序。

There are several steps. First remove the default handler for the delete button.

双击删除按钮

private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{

}

添加代码,在这种情况下,我使用自定义类来请求使用IDE生成的BindingSource删除当前行的权限。 / p>

Add code, in this case I'm using a custom class to ask permission to remove the current row using the BindingSource that the IDE generated.

private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
    var item = ((DataRowView)socialSecurityTableBindingSource.Current).Row.Field<int>("SocialSecurity");
    if (Question(


" Remove'{item}'"))
{
socialSecurityTableBindingSourceSource.RemoveCurrent();
}
}
"Remove '{item}'")) { socialSecurityTableBindingSource.RemoveCurrent(); } }

对话类

using System.Windows.Forms;

namespace MessageDialogs
{
    public static class KarenDialogs
    {
        public static bool Question(string Text)
        {
            return (MessageBox.Show(Text, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes);
        }
    }
}

屏幕截图

您也可以对其他按钮执行相同操作,例如我删除了添加的默认处理程序,然后使用这样的代码。

You can do the same for the other buttons too e.g. I remove the default handler for add then use code such as this.

private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
    if (Question(


" Add new record"))
{
socialSecurityTableBindingSourceSource.AddNew();
}
}
"Add new record")) { socialSecurityTableBindingSource.AddNew(); } }

对于保存,我们只需打包默认代码,如下所示,无需删除处理程序

For save we just wrap the default code as shown below, no need to remove the handler

private void socialSecurityTableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
    if (Question(


这篇关于工作导航器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆