美文网首页
.net(delegate)

.net(delegate)

作者: 成熟的青菜 | 来源:发表于2016-10-19 08:24 被阅读19次

<pre><code>

要刷新的窗体:
public partial class w_fareinfo : BaseForm
{

    public delegate void DelegateRefreshDGV(); //定义代理
    DataSet dsshipper = new DataSet();
    public List<ThisisLanQiaoSoft.客户管理.modelwf> li = new List<ThisisLanQiaoSoft.客户管理.modelwf>();
    commonclass cc = new commonclass(); Cls_SqlHelper cs = new Cls_SqlHelper();
}


    private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)  //新增数据
    {

        DelegateRefreshDGV dgv = new DelegateRefreshDGV(refreshDGV);
        wc_insert_customer wc = new wc_insert_customer(dgv);
        modelwf wf = new modelwf();

        wf.shippername = li[0].shippername;
        wf.pinming = li[0].pinming;
        wf.daozhan = li[0].daozhan;
        wc.li.Add(wf);
        wc.ShowDialog();
    }

    private void refreshDGV()//调用委托刷新的方法
    {
        getdata();
    }

第二个窗体:
public partial class wc_insert_customer : BaseForm

{

    private w_fareinfo.DelegateRefreshDGV dgv;

    commonclass cc = new commonclass(); Cls_SqlHelper cs = new Cls_SqlHelper();
    public  List<ThisisLanQiaoSoft.客户管理.modelwf> li = new List<ThisisLanQiaoSoft.客户管理.modelwf>();//修改接受的数据
    public List<ThisisLanQiaoSoft.客户管理.modelwf> lf = new List<ThisisLanQiaoSoft.客户管理.modelwf>();//新增
    public wc_insert_customer(w_fareinfo.DelegateRefreshDGV _dgv)
    {
        InitializeComponent();
        this.dgv = _dgv;
    }

}

思路:就是实体化的时候吧要刷新的窗体带到另一个窗体然后就可以调用要带的窗体里面的方法
</code></pre>
Here is an example of AppleScript: tell application "Foo" beep end tell

相关文章

网友评论

      本文标题:.net(delegate)

      本文链接:https://www.haomeiwen.com/subject/celuyttx.html