携带菜单条吗? [英] Carry over menustrip?

查看:102
本文介绍了携带菜单条吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将菜单条从一种形式携带到另一种形式?

我的项目有一个非常广泛的菜单栏,我不想复制每个表单的所有代码.

这有一个简单的可能性吗?还是完全有可能?

Is it possible to carry a menustrip from one form to the next?

My project has a very extensive menustrip, and i prefer not to copy all the code for each form.

Is there an easy possibility to this? Or, is it possible at all?

推荐答案

是的.您可以用代码创建菜单条(将其放入静态全局类中),然后将其添加到每个表单中(可能在表单的构造函数中).

此时,您要做的就是为菜单项添加事件处理程序.

您还可以创建一个包含menustrip的基窗体类,然后从该新基类派生新窗体.那时,如果您对编码很聪明,就不必在每种形式中添加事件处理程序.
Yes. You can create the menu strip in code (put it in a static global class), and then add it to each form (probably in the form''s constructor).

At that point, all you have to do is add event handlers for the menu items.

You can also create a base form class that contains the menustrip, and then derive new forms from that new base class. At that point, you don''t have to add event handlers in each form if you''re clever about your coding.


这篇关于携带菜单条吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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