How to raise an event between two different forms ( of the same program)

喜夏-厌秋 提交于 2019-12-24 05:21:50

问题


I have a MDI form that will open a logon form so the user can be authenticated

when the user hits the logon button and is properly authenticated i wanted to trigger an event that the parent form could pick up and change some variables ((authenticated = true) for example)

I understand how to do this in something like a textbox or a costume usercontrol but im not clear on how to do it between forms because i usually do it through the designer view

can someone walk me through triggering an event on a diffrent form?


回答1:


In the parent form, something like:

loginForm.Authenticated += MyEventHandler;

or

loginForm.Authenticated += delegate { /* Code here */ };

or

loginForm.Authenticated += (sender, args) => { /* Code here */ };


来源:https://stackoverflow.com/questions/1069474/how-to-raise-an-event-between-two-different-forms-of-the-same-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!