表格引用的问题 [英] Question with form refernce

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

问题描述

大家好,



我有一个可以在不同时间从3个工具条菜单项调用的表单。从该表单中你可以选择一个项目和根据选择继续进行另一个表单。因为他们共享这个表单所持有的项目。

现在我希望这个表单确定哪个工具条菜单项称为它,然后显示相关表单。这是可能的,而不是为了相同的目的创建相同的形式吗?

Hi guys,

I have a form that could be called from 3 tool strip menu items at different times.And from that form you can select an item and proceed to another form based on the selection.Since they share the items this form is holding.
Now i want this form to determine which tool strip menu item called it,and then to display the relevant forms.Is that possible,rather than creating identical form for the same purpose?

推荐答案

这是...但它是一个糟糕的主意,因为它违反了OOP原则,并且将表单与菜单绑定到菜单显示的表单,因此您无法在不考虑表单效果的情况下更改菜单。



更好的想法是在新表单中创建一个事件,该表单使用菜单在表单中处理,并引发相应的其他表单。这样,OOPs设计得以维持。



这很简单: http://msdn.microsoft.com/en-us/library/2z7x8ys3(v = vs.90).aspx [ ^ ] - 您创建事件,然后附加在显示之前创建新表单实例的处理程序。
It is...but it's a poor idea, because it violates the OOPs principles, and ties the form with the menu to the form the menu displays, so you can't change the menu without considering the effects on the form.

A better idea is to create an event in the new form which is handled in the form with the menu, and it raises the appropriate other form. That way, OOPs design is maintained.

It's pretty simple: http://msdn.microsoft.com/en-us/library/2z7x8ys3(v=vs.90).aspx[^] - you create the event, then attach a handler when you creat ethe new form instance, before you display it.


这篇关于表格引用的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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