处理动态创建的表单的关闭事件 [英] Handle closing event for dynamically created form

查看:21
本文介绍了处理动态创建的表单的关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序正在运行,它可以从硬件中读取数据.我的程序能够以用户指定的速率绘制这些传入值.(使用 zedgraph 控件).当用户选择绘制这些值时,会动态创建一个包含该图形的新表单.

I have a program up and running that can read in data from a piece of hardware. My program has the ability to graph these incoming values at rates specified by the user. (Using a zedgraph control). When the user chooses to graph the values, a new form is dynamically created that contains the graph.

实际上,用户可以拥有任意数量的图表.我的问题是我需要为那些动态创建的表单(包含图形)关闭时创建一个事件处理程序.我知道对于我的主 UI,我可以只使用设计器工具并单击关闭的事件来创建处理程序.但是,我不确定如何为动态创建的表单执行此操作.

In practice, a user can have as many graphs as they want. My problem is I need to create an event handler for when those dynamically created forms (containing the graphs) are closed. I know for my main UI I can just use the designer tool and click the closed event to make a handler. However I'm not sure how to do this for a dynamically created form.

感谢任何建议!

推荐答案

设计师没有做任何花哨的事情.您可以在 .Designer.cs 文件中看到它在做什么.以下是您自己动手的方法:

The designer isn't doing anything fancy. You can see what it's doing in the .Designer.cs file. Here's how you do it yourself:

myDynamicForm.FormClosing += new FormClosingEventHandler(your_handler_method);

这篇关于处理动态创建的表单的关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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