使用其他形式的按钮引发事件 [英] Using button in other form to raise an event

查看:129
本文介绍了使用其他形式的按钮引发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2种形式,在子形式中是一个按钮,当单击某些按钮时
必须执行主表单上的代码.

我尝试过:

I have 2 forms, in the sub form is a button, when it is clicked some
code on the main form has to be executed.

I tried it with:

rowpopup^ popup = gcnew rowpopup();
popup->button_savetoform->Click += gcnew EventHandler(this, &Main::add_new_item);



它将编译,但是当我单击按钮时未输入子add_new_item.



It will compile, but when I click the button the sub add_new_item is not being entered.

推荐答案

在使用托管C ++时,请使用委托进行挂钩可以从您的主要形式事先准备好该事件.
As you''re using managed C++, use delegates to hook up this event before hand, from your main form.


这篇关于使用其他形式的按钮引发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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